diff options
author | devin ivy <devinivy@gmail.com> | 2024-06-27 13:02:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 13:02:29 -0400 |
commit | 49396451ec8c877aebd27299a98c1b9e5b1e6cd4 (patch) | |
tree | c424c554a431c9594896a09bf422c737c2341e62 /bskyogcard/scripts | |
parent | f6b138f709bcf52248e3f0c5a1ef67abe96bef9c (diff) | |
download | voidsky-49396451ec8c877aebd27299a98c1b9e5b1e6cd4.tar.zst |
bskyogcard: support emoji, more languages, long starter pack names (#4668)
Diffstat (limited to 'bskyogcard/scripts')
-rw-r--r-- | bskyogcard/scripts/install-fonts.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bskyogcard/scripts/install-fonts.ts b/bskyogcard/scripts/install-fonts.ts new file mode 100644 index 000000000..5c58fb7b9 --- /dev/null +++ b/bskyogcard/scripts/install-fonts.ts @@ -0,0 +1,40 @@ +import {writeFile} from 'node:fs/promises' +import * as path from 'node:path' +import {fileURLToPath} from 'node:url' + +const __DIRNAME = path.dirname(fileURLToPath(import.meta.url)) + +const FONTS = [ + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-jp@5.0/japanese-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-tc@5.0/chinese-traditional-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-sc@5.0/chinese-simplified-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-hk@5.0/chinese-hongkong-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-kr@5.0/korean-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-thai@5.0/thai-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-arabic@5.0/arabic-700-normal.ttf', + 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-hebrew@5.0/hebrew-700-normal.ttf', +] + +async function main() { + await Promise.all( + FONTS.map(async urlStr => { + const url = new URL(urlStr) + const res = await fetch(url) + const font = await res.arrayBuffer() + const filename = url.pathname + .split('/') + .slice(-2) + .join('/') + .replace(/@[\d.]+\//, '-') + if (!res.ok) { + throw new Error(`HTTP ${res.status}: fetching failed for ${filename}`) + } + await writeFile( + path.join(__DIRNAME, '..', 'src', 'assets', 'fonts', filename), + Buffer.from(font), + ) + }), + ) +} + +main() |