Skip to content

Instantly share code, notes, and snippets.

@dreamyguy
Created August 31, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamyguy/764553bfd290bb8699f21ed61dc7c22d to your computer and use it in GitHub Desktop.
Save dreamyguy/764553bfd290bb8699f21ed61dc7c22d to your computer and use it in GitHub Desktop.
SCSS Webfont pattern
$font-fallback: arial, sans-serif;
$path-fonts: '../fonts';
.font-defaults {
font-weight: normal;
font-style: normal;
-webkit-font-smoothing: antialiased;
}
@font-face {
font-family: 'AzoSansBlack';
src: url('#{$path-fonts}/AzoSans-Black-webfont.eot');
src: url('#{$path-fonts}/AzoSans-Black-webfont.eot?#iefix') format("embedded-opentype"), url('#{$path-fonts}/AzoSans-Black-webfont.woff') format("woff"), url('#{$path-fonts}/AzoSans-Black-webfont.ttf') format("truetype"), url('#{$path-fonts}/AzoSans-Black-webfont.svg#AzoSansBlack') format("svg");
@extend .font-defaults;
}
@font-face {
font-family: 'AzoSansLight';
src: url('#{$path-fonts}/AzoSans-Light-webfont.eot');
src: url('#{$path-fonts}/AzoSans-Light-webfont.eot?#iefix') format("embedded-opentype"), url('#{$path-fonts}/AzoSans-Light-webfont.woff') format("woff"), url('#{$path-fonts}/AzoSans-Light-webfont.ttf') format("truetype"), url('#{$path-fonts}/AzoSans-Light-webfont.svg#AzoSansLight') format("svg");
@extend .font-defaults;
}
@font-face {
font-family: 'AzoSansLightItalic';
src: url('#{$path-fonts}/AzoSans-Light-Italic-webfont.eot');
src: url('#{$path-fonts}/AzoSans-Light-Italic-webfont.eot?#iefix') format("embedded-opentype"), url('#{$path-fonts}/AzoSans-Light-Italic-webfont.woff') format("woff"), url('#{$path-fonts}/AzoSans-Light-Italic-webfont.ttf') format("truetype"), url('#{$path-fonts}/AzoSans-Light-Italic-webfont.svg#AzoSansLightItalic') format("svg");
@extend .font-defaults;
}
@font-face {
font-family: 'AzoSansMedium';
src: url('#{$path-fonts}/AzoSans-Medium-webfont.eot');
src: url('#{$path-fonts}/AzoSans-Medium-webfont.eot?#iefix') format("embedded-opentype"), url('#{$path-fonts}/AzoSans-Medium-webfont.woff') format("woff"), url('#{$path-fonts}/AzoSans-Medium-webfont.ttf') format("truetype"), url('#{$path-fonts}/AzoSans-Medium-webfont.svg#AzoSansMedium') format("svg");
@extend .font-defaults;
}
.font-azo-black {
font-family: 'AzoSansBlack', $font-fallback;
}
.font-azo-light {
font-family: 'AzoSansLight', $font-fallback;
}
.font-azo-light-italic {
font-family: 'AzoSansLightItalic', $font-fallback;
}
.font-azo-medium {
font-family: 'AzoSansMedium', $font-fallback;
}
// User cases:
//
// 1.
// <p class="font-azo-medium">A Very Special P</p>
//
// 2.
// h2 {
// font-size: 38px;
// line-height: .8;
// @extend .font-azo-medium;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment