Spaces:
Running
Running
Update: ≤3s WeChat-compatible live photos, sets 3 & 4 (fill-in-the-blank), in-browser maker tool
0daf81d verified Download source/frontend/src/lib/live/fonts.ts from Ethscriptions/eths: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/Ethscriptions/eths/resolve/main/source/frontend/src/lib/live/fonts.ts
- Command line
-
hf download hf://spaces/Ethscriptions/eths/source/frontend/src/lib/live/fonts.ts
-
curl -L -o fonts.ts https://huggingface.co/spaces/Ethscriptions/eths/resolve/main/source/frontend/src/lib/live/fonts.ts
1.3 kB
| // 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<void> | null = null | |
| export function loadFonts(): Promise<void> { | |
| 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 | |
| } | |