Skip to content

Instantly share code, notes, and snippets.

@Djules
Forked from diogomoretti/fonts.styl
Last active August 29, 2015 14:01
Show Gist options
  • Save Djules/e564bc795ae11fed8902 to your computer and use it in GitHub Desktop.
Save Djules/e564bc795ae11fed8902 to your computer and use it in GitHub Desktop.
Updated Stylus mixin @font-face
// Fonts mixin
font-file(file, ext, path)
return path + file + ext
webfont(family, file, path = '../fonts/', hack-chrome-windows = false, weight = 'normal', style = 'normal')
@font-face
font-family family
src url(font-file(file, '.eot', path))
src url(font-file(file, '.eot?#iefix', path)) format('embedded-opentype'),
url(font-file(file, '.woff', path)) format('woff'),
url(font-file(file, '.ttf', path)) format('truetype'),
url(font-file(file, '.svg#'+ family, path)) format('svg')
font-weight weight
font-style style
if hack-chrome-windows
@media screen and (-webkit-min-device-pixel-ratio:0)
@font-face
font-family family
src url(font-file(file, '.svg#'+ family, path)) format('svg')
@Djules
Copy link
Author

Djules commented May 23, 2014

Added path for font files location, and style for font-style attribute.

How to use :

webfont('Open Sans', 'open-sans-webfont-italic', '../fonts/', true, 'normal', 'italic')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment