build: add Manrope font bundling script

This commit is contained in:
Your Name
2026-03-11 23:53:56 -05:00
parent 2e457bee42
commit 9d964ab681
2 changed files with 26 additions and 0 deletions
+3
View File
@@ -69,3 +69,6 @@ release_notes.md
/docs/plans/2026-03-11-recurring-group-propagation-design.md
/docs/plans/2026-03-11-seed-backup-restore.md
/docs/plans/2026-03-11-seed-backup-restore-design.md
/docs/plans/2026-03-12-ui-redesign-design.md
/docs/plans/2026-03-12-ui-redesign.md
/src/ui/fonts.js
+23
View File
@@ -0,0 +1,23 @@
const fs = require('fs')
const path = require('path')
const BASE = path.join(__dirname, '../node_modules/@fontsource/manrope/files')
const OUT = path.join(__dirname, '../src/ui/fonts.js')
const weights = [
{ w: 300, file: 'manrope-latin-300-normal.woff2' },
{ w: 400, file: 'manrope-latin-400-normal.woff2' },
{ w: 500, file: 'manrope-latin-500-normal.woff2' },
]
let css = ''
for (const { w, file } of weights) {
const filePath = path.join(BASE, file)
if (!fs.existsSync(filePath)) { console.error('Missing:', filePath); process.exit(1) }
const b64 = fs.readFileSync(filePath).toString('base64')
css += `@font-face{font-family:'Manrope';font-style:normal;font-weight:${w};`
css += `font-display:swap;src:url("data:font/woff2;base64,${b64}") format("woff2");}\n`
}
fs.writeFileSync(OUT, `// AUTO-GENERATED by scripts/gen-fonts.js — do not edit\nexport const FONT_CSS = ${JSON.stringify(css)}\n`)
console.log('fonts.js written —', Math.round(fs.statSync(OUT).size / 1024), 'KB')