Created
August 1, 2017 22:18
-
-
Save denar90/8ddcde2f80561b1422ecf3673b83d519 to your computer and use it in GitHub Desktop.
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
var notoSansRegular = new FontFace('Noto Sans Regular', 'url(/fonts/NotoSans-Regular.woff2)', { | |
style: 'normal', | |
weight: '400' | |
}); | |
// add new font | |
document.fonts.add(notoSansRegular); | |
// load font | |
notoSansRegular.load(); | |
//check status | |
notoSansRegular.loaded.then((fontFace) => { | |
// This is where you can declare a new font-family, because the font is now loaded and ready. | |
console.info('Current status', fontFace.status); | |
console.log(fontFace.family, 'loaded successfully.'); | |
// Throw an error if loading wasn't successful | |
}, (fontFace) => { | |
console.error('Current status', notoSansRegular.status); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment