Skip to content

Instantly share code, notes, and snippets.

@yumyo
Last active July 28, 2016 13:40
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 yumyo/d88da3475006d8bc2c77edbaf6c5ae38 to your computer and use it in GitHub Desktop.
Save yumyo/d88da3475006d8bc2c77edbaf6c5ae38 to your computer and use it in GitHub Desktop.

#font-loaded mixin

To be used along with the FontFaceObserver approach https://github.com/bramstein/fontfaceobserver

##Usage

// Example with global variables.
$safe-serif: Georgia, serif;
$custom-serif: 'Tiempos Text Bold', $safe-serif;

.element {
  @include font-loader($safe-serif, $custom-serif);
}

Which compiles in:

.element {
  font-family: Georgia, serif;
}

.fonts-loaded .element {
  font-family: "Tiempos Text Bold", Georgia, serif;
}
@mixin font-loaded($safe-family, $custom-family) {
.fonts-loaded & {
font-family: $custom-family;
}
font-family: $safe-family;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment