Skip to content

Instantly share code, notes, and snippets.

@paceaux
Created October 2, 2013 16:16
Show Gist options
  • Save paceaux/6796255 to your computer and use it in GitHub Desktop.
Save paceaux/6796255 to your computer and use it in GitHub Desktop.
Stylus font functions. Add this to a vars.styl file that you would import all over the place.
//========== root values
phi = 1.618
fi = .618
golden = 1.61803398875
rootPx = 16px
rootEm = 1em
rootPercent = 100%
rootPt = pxToPt(rootPx)
//========== font functions
hifi()
unit(phi, 'em')
lofi()
unit(fi, 'em')
rem(n)
rootEm * n
pxToPt(n)
unit(.75 * n,pt)
ptToPx(n)
ceil(unit(n * 1.333333333,px))
ptToEm(n)
unit(ptToPx(n) / rootPx,em)
emToPx(n)
unit(n * 16,px)
pxToEm(n)
unit(n/rootEm,em)
emToPercent(n)
(n/rootEm)%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment