Skip to content

Instantly share code, notes, and snippets.

@webfacer
Last active August 29, 2015 14:10
Show Gist options
  • Save webfacer/5e9911051d3684ef421f to your computer and use it in GitHub Desktop.
Save webfacer/5e9911051d3684ef421f to your computer and use it in GitHub Desktop.
scss easy font family generator
//** File name for all font files.
$font-name: "Test" !default;
//** Element ID within SVG icon file.
$font-weights: (
"Light": "light",
"Medium": "medium",
"Regular": "regular",
"Thin": "thin",
"Bold": "bold",
"ExtraBold": "extrabold",
"Black": "black",
"Heavy": "heavy",
);
@each $font-weight-name, $font-file in $font-weights {
//@todo should check if font files exists, since not every font support as an example .woff and .woff2
@font-face {
font-family : '#{$font-name}-#{$font-weight-name}';
src : url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$font-path}#{$font-file}.eot'), '#{$font-path}#{$font-file}.eot'));
src : url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$font-path}#{$font-file}.eot?#iefix'), '#{$font-path}#{$font-file}.eot?#iefix')) format('embedded-opentype'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$font-path}#{$font-file}.woff2'), '#{$font-path}#{$font-file}.woff2')) format('woff2'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$font-path}#{$font-file}.woff'), '#{$font-path}#{$font-file}.woff')) format('woff'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$font-path}#{$font-file}.ttf'), '#{$font-path}#{$font-file}.ttf')) format('truetype')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment