File size: 819 Bytes
4d70170 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import { ref } from 'vue'
import * as PIXI from 'pixi.js-legacy'
let installedFonts = false
export async function installFonts() {
if (installedFonts) {
return
}
try {
await document.fonts.load('10px "Roboto Mono"')
}
catch (e) {
console.error(e)
}
PIXI.BitmapFont.from('roboto-black', {
fontFamily: 'Roboto Mono',
fontSize: 9,
fill: '#000000',
}, {
resolution: window.devicePixelRatio,
})
PIXI.BitmapFont.from('roboto-white', {
fontFamily: 'Roboto Mono',
fontSize: 9,
fill: '#ffffff',
}, {
resolution: window.devicePixelRatio,
})
installedFonts = true
}
export function useFonts() {
const loaded = ref(installedFonts)
async function _load() {
await installFonts()
loaded.value = true
}
_load()
return {
loaded,
}
}
|