Skip to content

Instantly share code, notes, and snippets.

@denar90
Created August 1, 2017 22:18
Show Gist options
  • Save denar90/8ddcde2f80561b1422ecf3673b83d519 to your computer and use it in GitHub Desktop.
Save denar90/8ddcde2f80561b1422ecf3673b83d519 to your computer and use it in GitHub Desktop.
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