Created
June 23, 2018 16:44
-
-
Save spences10/357c968bb3da14d25916c233c1a76703 to your computer and use it in GitHub Desktop.
Font Face helper function by mschipperheyn
This file contains 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
/** | |
* 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