Skip to content

Instantly share code, notes, and snippets.

@adammcfadden
Last active June 26, 2021 10:18
Show Gist options
  • Save adammcfadden/be35054aaab5c36ab421282e3399a4e3 to your computer and use it in GitHub Desktop.
Save adammcfadden/be35054aaab5c36ab421282e3399a4e3 to your computer and use it in GitHub Desktop.
Vue component for loading minimal fonts with webfontloader
// Vue component for loading minimal fonts with webfontloader
<template>
</template>
<script>
//https://github.com/typekit/webfontloader
import WebFontLoader from 'webfontloader';
export default {
created() {
WebFontLoader.load({
custom: {
// Use FVD notation to include families https://github.com/typekit/fvd
families: ['Rubik:n4,n5,n7'],
// Path to stylesheet that defines font-face
urls: ['/static/assets/fonts/stylesheet.css'],
},
active: this.setFontLoaded,
});
},
methods: {
setFontLoaded() {
this.$emit('font-loaded');
},
},
};
</script>
@borodadada
Copy link

it's not work on SSR, and yes "window is not defined"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment