Created
April 13, 2015 16:42
-
-
Save brumm/5b76b269b32cca33dbeb to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// libsass (v3.1.0) | |
// ---- | |
$asset-pipeline: false; | |
@mixin font-face( | |
$font-family, | |
$file-path, | |
$weight: normal, | |
$style: normal, | |
$asset-pipeline: $asset-pipeline, | |
$file-formats: eot woff2 woff ttf svg) { | |
$font-url-prefix: font-url-prefixer($asset-pipeline); | |
@font-face { | |
font-family: $font-family; | |
font-style: $style; | |
font-weight: $weight; | |
src: font-source-declaration( | |
$font-family, | |
$file-path, | |
$asset-pipeline, | |
$file-formats, | |
$font-url-prefix | |
); | |
} | |
} | |
// Used for creating the source string for fonts using @font-face | |
// Reference: http://goo.gl/Ru1bKP | |
@function font-url-prefixer($asset-pipeline) { | |
@if $asset-pipeline == true { | |
@return font-url; | |
} @else { | |
@return url; | |
} | |
} | |
@function font-source-declaration( | |
$font-family, | |
$file-path, | |
$asset-pipeline, | |
$file-formats, | |
$font-url) { | |
$src: null; | |
$formats-map: ( | |
eot: "#{$file-path}.eot?#iefix" format("embedded-opentype"), | |
woff2: "#{$file-path}.woff2" format("woff2"), | |
woff: "#{$file-path}.woff" format("woff"), | |
ttf: "#{$file-path}.ttf" format("truetype"), | |
svg: "#{$file-path}.svg##{$font-family}" format("svg") | |
); | |
@each $key, $values in $formats-map { | |
@if contains($file-formats, $key) { | |
$file-path: nth($values, 1); | |
$font-format: nth($values, 2); | |
@if $asset-pipeline == true { | |
$src: append($src, font-url($file-path) $font-format, comma); | |
} @else { | |
$src: append($src, url($file-path) $font-format, comma); | |
} | |
} | |
} | |
@return $src; | |
} | |
@include font-face(MavenPro, 'fonts/maven-pro/regular/maven-pro-regular-webfont', 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@font-face { | |
font-family: MavenPro; | |
font-style: normal; | |
font-weight: 100; | |
src: url("fonts/maven-pro/regular/maven-pro-regular-webfont.eot?#iefix") format("embedded-opentype"), url("fonts/maven-pro/regular/maven-pro-regular-webfont.woff2") format("woff2"), url("fonts/maven-pro/regular/maven-pro-regular-webfont.woff") format("woff"), url("fonts/maven-pro/regular/maven-pro-regular-webfont.ttf") format("truetype"), url("fonts/maven-pro/regular/maven-pro-regular-webfont.svg#MavenPro") format("svg"); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment