build: add Manrope font bundling script
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
Reference in New Issue
Block a user