Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active November 1, 2017 16:53
Show Gist options
  • Save daliborgogic/0bc37b82b2a27d51038f0874261595a0 to your computer and use it in GitHub Desktop.
Save daliborgogic/0bc37b82b2a27d51038f0874261595a0 to your computer and use it in GitHub Desktop.
CSS Font Loading Module Level 3
<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