Skip to content

Instantly share code, notes, and snippets.

@julienbourdeau
Created March 1, 2015 20:43
Show Gist options
  • Save julienbourdeau/1235f357d4da4d69d330 to your computer and use it in GitHub Desktop.
Save julienbourdeau/1235f357d4da4d69d330 to your computer and use it in GitHub Desktop.
Scss Font Face Mixin
@mixin font-face($style-name, $file, $family, $category:"") {
$filepath: "fonts/" + $family + "/" + $file;
@font-face {
font-family: "#{$style-name}";
src: url($filepath + ".eot");
src: url($filepath + ".eot?#iefix") format('embedded-opentype'), url($filepath + ".woff") format('woff'), url($filepath + ".ttf") format('truetype'), url($filepath + ".svg#" + $style-name + "") format('svg');
}
%#{$style-name} {
font: {
@if $category != "" {
family: "#{$style-name}", #{$category};
}
@else {
family: "#{$style-name}";
weight: normal;
}
}
}
}
@julienbourdeau
Copy link
Author

Use this way:

@include font-face('Ashbury', 'AshburyLig-webfont', 'Ashbury', 'serif');

Source : http://clubmate.fi/scss-font-face-mixin/

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