Skip to content

Instantly share code, notes, and snippets.

@spences10
Created June 23, 2018 16:44
Show Gist options
  • Save spences10/357c968bb3da14d25916c233c1a76703 to your computer and use it in GitHub Desktop.
Save spences10/357c968bb3da14d25916c233c1a76703 to your computer and use it in GitHub Desktop.
Font Face helper function by mschipperheyn
/**
* Awesome helper function from Marc Schipperheyn
* https://github.com/mschipperheyn 👌
*
*/
export function fontFace(
name,
src,
fontWeight = 'normal',
fontStyle = 'regular'
) {
return `
@font-face{
font-family: "${name}";
src: url(${require('../fonts/' + src + '.eot')});
src: url(${require('../fonts/' +
src +
'.eot')}?#iefix) format("embedded-opentype"),
url(${require('../fonts/' +
src +
'.woff')}) format("woff"),
url(${require('../fonts/' +
src +
'.ttf')}) format("truetype"),
url(${require('../fonts/' +
src +
'.svg')}#${name}) format("svg");
font-style: ${fontStyle};
font-weight: ${fontWeight};
}
`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment