Skip to content

Instantly share code, notes, and snippets.

@billinghamj
Created April 9, 2013 17:12
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 billinghamj/5347498 to your computer and use it in GitHub Desktop.
Save billinghamj/5347498 to your computer and use it in GitHub Desktop.
A better way to declare lots of font-faces
@import 'compass/css3/font-face';
@mixin nice-font-face($name, $directoryName, $svg, $weights, $style, $fileSuffix: '', $nameOverride: false)
{
@each $weight in $weights
{
$path: $directoryName + '/';
$files: '';
@if ($nameOverride)
{
$path: $path + $nameOverride;
}
@else
{
$path: $path + $weight;
}
$path: $path + $fileSuffix + '.';
@if ($svg)
{
$files: font-files($path + 'woff', woff, $path + 'ttf', ttf, $path + 'svg', svg);
}
@else
{
$files: font-files($path + 'woff', woff, $path + 'ttf', ttf);
}
@include font-face($name, $files, $path + 'eot', $weight, $style);
}
}
@include nice-font-face('Proxima Nova', 'proxima-nova', false, 300 400 600 700 800 900, normal);
@include nice-font-face('Proxima Nova', 'proxima-nova', false, 300 400 600 700, italic, '_i');
@include nice-font-face('Open Sans', 'open-sans', false, 300 400 600 700 800, normal);
@include nice-font-face('Open Sans', 'open-sans', false, 300 400 600 700 800, italic, '_i');
@include nice-font-face('Batch', 'batch', true, 100 200 300 400 500 600 700 800 900, normal, '', 'all');
@include nice-font-face('Batch', 'batch', true, 100 200 300 400 500 600 700 800 900, italic, '', 'all');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment