// Self-hosted fonts (no Google Fonts, works in mainland China). const base = `${import.meta.env.BASE_URL}fonts/` const FACES: [string, string, string][] = [ ['LW SC', 'lw-sc-500.woff2', '500'], ['LW SC', 'lw-sc-700.woff2', '700'], ['LW Smiley', 'lw-smiley.woff2', '400'], ['LW Poppins', 'lw-poppins-800.woff2', '800'], ['LW Poppins', 'lw-poppins-600.woff2', '600'], ['LW IPA', 'lw-ipa-500.woff2', '500'], ] export const FONT = { sc: (w: number, px: number) => `${w} ${px}px "LW SC", "PingFang SC", "Microsoft YaHei", sans-serif`, head: (px: number) => `400 ${px}px "LW Smiley", "LW SC", "PingFang SC", sans-serif`, word: (px: number) => `800 ${px}px "LW Poppins", "Helvetica Neue", Arial, sans-serif`, wordSemi: (px: number) => `600 ${px}px "LW Poppins", "Helvetica Neue", Arial, sans-serif`, ipa: (px: number) => `500 ${px}px "LW IPA", "Lucida Sans Unicode", "Arial Unicode MS", sans-serif`, } let loading: Promise | null = null export function loadFonts(): Promise { if (loading) return loading loading = Promise.all( FACES.map(async ([family, file, weight]) => { const f = new FontFace(family, `url(${base}${file})`, { weight, display: 'block' }) await f.load() document.fonts.add(f) }), ).then(() => undefined) return loading }