Skip to content

Instantly share code, notes, and snippets.

@piouPiouM
Forked from Kozlika/SassMeister-input.scss
Last active March 25, 2016 14: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 piouPiouM/b1a3086e18682906a160 to your computer and use it in GitHub Desktop.
Save piouPiouM/b1a3086e18682906a160 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
// Settings
// ===========================================
$fonts-map: (
'sourcesanspro':
( // sera utilisé comme valeur pour la font-family de ce groupe
(
'font-path' : "sourcesanspro_regular_macroman/SourceSansPro-Regular-webfont",
'font-weight' : 400,
'font-style' : normal
) ,
(
'font-path' : "sourcesanspro_semibold_macroman/SourceSansPro-Semibold",
'font-weight' : 600,
'font-style' : normal
) ,
(
'font-path' : "sourcesanspro_italic_macroman/SourceSansPro-It-webfont",
'font-weight' : 400,
'font-style' : italic
)
),
'martel':
( // sera utilisé comme valeur pour la font-family de ce groupe
(
'font-path' : "martel/martel-regular-webfont",
'font-weight' : 400,
'font-style' : normal
)
)
);
$map: $fonts-map !default;
$webfont-path: "../webfont/" !default;
// Mixin
// ===========================================
// Import unitaire fonte
/// @include sc-import-font(roboto, 'chemin/vers/roboto');
@mixin sc-import-font($fonte, $font_path, $font_weight: normal, $font_style: "") {
$family: quote( #{$fonte} );
$wf-src: $webfont-path + $font-path;
@font-face {
font-family: $family;
src: url($wf-src + ".eot");
src: url($wf-src + ".eot?#iefix") format('embedded-opentype'),
url($wf-src + ".woff") format('woff'),
url($wf-src + ".ttf") format('truetype');
font-weight: #{$font-weight};
font-style: #{$font-style};
}
}
// Importe chaque font de la $map
/// @include sc-import-fonts($map);
@mixin sc-import-fonts($map) {
@each $font-group, $font in $map {
// Cas d'un ensemble de variantes, composées de map des propriétés de la
// font-face (ie. "sourcesanspro").
@if "list" == type-of($font) {
@each $variante in $font {
@include sc-import-fonts(($font-group: $variante));
}
}
// Cas final : l'item courant est une map des propriétés de la font-face
// (ie. "martel" qui n'a qu'une variante).
@else if "map" == type-of($font) {
@include sc-import-font($font-group, $font...);
}
}
}
// Test
// ===========================================
@include sc-import-fonts($map);
@font-face {
font-family: "sourcesanspro";
src: url("../webfont/sourcesanspro_regular_macroman/SourceSansPro-Regular-webfont.eot");
src: url("../webfont/sourcesanspro_regular_macroman/SourceSansPro-Regular-webfont.eot?#iefix") format("embedded-opentype"), url("../webfont/sourcesanspro_regular_macroman/SourceSansPro-Regular-webfont.woff") format("woff"), url("../webfont/sourcesanspro_regular_macroman/SourceSansPro-Regular-webfont.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: "sourcesanspro";
src: url("../webfont/sourcesanspro_semibold_macroman/SourceSansPro-Semibold.eot");
src: url("../webfont/sourcesanspro_semibold_macroman/SourceSansPro-Semibold.eot?#iefix") format("embedded-opentype"), url("../webfont/sourcesanspro_semibold_macroman/SourceSansPro-Semibold.woff") format("woff"), url("../webfont/sourcesanspro_semibold_macroman/SourceSansPro-Semibold.ttf") format("truetype");
font-weight: 600;
font-style: normal;
}
@font-face {
font-family: "sourcesanspro";
src: url("../webfont/sourcesanspro_italic_macroman/SourceSansPro-It-webfont.eot");
src: url("../webfont/sourcesanspro_italic_macroman/SourceSansPro-It-webfont.eot?#iefix") format("embedded-opentype"), url("../webfont/sourcesanspro_italic_macroman/SourceSansPro-It-webfont.woff") format("woff"), url("../webfont/sourcesanspro_italic_macroman/SourceSansPro-It-webfont.ttf") format("truetype");
font-weight: 400;
font-style: italic;
}
@font-face {
font-family: "martel";
src: url("../webfont/martel/martel-regular-webfont.eot");
src: url("../webfont/martel/martel-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../webfont/martel/martel-regular-webfont.woff") format("woff"), url("../webfont/martel/martel-regular-webfont.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment