Last active
November 1, 2017 16:53
-
-
Save daliborgogic/0bc37b82b2a27d51038f0874261595a0 to your computer and use it in GitHub Desktop.
CSS Font Loading Module Level 3
This file contains hidden or 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
<template> | |
<div id="app">The quick brown fox jumps over the lazy dog</div> | |
</template> | |
<script> | |
async function loadFont () { | |
const font = new FontFace('Hack Regular', 'url(./hack-regular.woff2)') | |
await font.load() | |
document.fonts.add(font) | |
document.getElementById('app').classList.add('font-loaded') | |
} | |
export default { | |
beforeMount () { loadFont() } | |
} | |
</script> | |
<style> | |
#app { font-family: Arial, sans-serif; } | |
#app.font-loaded { font-family: 'Hack Regular', monospace; } | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment