Skip to content

Instantly share code, notes, and snippets.

@isellsoap
Created September 30, 2015 12:19
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 isellsoap/7a4ead66d7d015a4b541 to your computer and use it in GitHub Desktop.
Save isellsoap/7a4ead66d7d015a4b541 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
/**
* Output the `@font-face` declarations.
*
* @param {Map} $fonts [$szfonts-registry] - The font registry.
* @param {List} $fileTypes ['eot' 'woff2' 'woff' 'otf'] – File types to output.
*
* @requires {variable} szfonts-registry
* @requires {function} szfonts-compose-path
* @requires {function} szfonts-compose-file-name
* @requires {function} szfonts-weight
*
* @link http://www.paulirish.com/2009/bulletproof-font-face-implementation-syntax/
*
* @group szfonts
*/
@mixin szfonts-font-face($fonts: $szfonts-registry, $fileTypes: 'eot' 'woff2' 'woff' 'otf') {
$hasEot: index($fileTypes, 'eot') != null;
@if $hasEot and nth($fileTypes, 1) != 'eot' {
@error ".eot file type must be declared firstly.";
}
@each $family, $font in $fonts {
@each $key, $properties in $font {
$weight: map-get($properties, weight);
$style: map-get($properties, style);
$stretch: map-get($properties, stretch);
$path: szfonts-compose-path($family);
$file-name: szfonts-compose-file-name($family, $weight, $style, $stretch);
// make sure the declarations will not be nested
@at-root {
@font-face {
font-family: $family;
font-stretch: unquote($stretch);
font-style: unquote($style);
font-weight: szfonts-weight($weight);
$formats: (
eot: 'embedded-opentype',
otf: 'opentype'
);
$result: ();
@each $fileType in $fileTypes {
$format: if(map-has-key($formats, $fileType), map-get($formats, $fileType), $fileType);
$isEot: $fileType == 'eot';
@if $isEot {
src: url($path + $file-name + '.' + $fileType);
}
$result: append($result, url(quote($path + $file-name + "." + $fileType + if($isEot, '?#iefix', ''))) format(quote($format)), comma);
}
src: $result;
}
}
}
}
}
@charset "UTF-8";
/**
* Output the `@font-face` declarations.
*
* @param {Map} $fonts [$szfonts-registry] - The font registry.
* @param {List} $fileTypes ['eot' 'woff2' 'woff' 'otf'] – File types to output.
*
* @requires {variable} szfonts-registry
* @requires {function} szfonts-compose-path
* @requires {function} szfonts-compose-file-name
* @requires {function} szfonts-weight
*
* @link http://www.paulirish.com/2009/bulletproof-font-face-implementation-syntax/
*
* @group szfonts
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment