From 4b3d475d781ad22c66c004c0223c8edda4d99274 Mon Sep 17 00:00:00 2001 From: odex21 Date: Tue, 21 Jul 2026 19:21:36 +0800 Subject: [PATCH] feat(build): --font-regular/--font-bold source overrides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lets a target bake subset or alternative TTFs without replacing the shared assets in the tree — the ESP32-P4 lyrics firmware uses a subset CJK font to fit the app partition, while desktop/web builds keep the stock fonts. --- tools/build.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/build.ts b/tools/build.ts index f3484672..c443f501 100644 --- a/tools/build.ts +++ b/tools/build.ts @@ -17,6 +17,9 @@ // --config= load a Pocket config file (default: pocket.config.ts) // --no-config ignore pocket.config.ts // --extra-chars= force extra codepoints into every atlas +// --density= low-level target sampling density (default 1) +// --font-regular= override the regular font source +// --font-bold= override the bold font source // --outdir= write .js/.pak here instead of dist/ // (external repos build their apps against a // vendored PocketJS and keep outputs local) @@ -74,6 +77,8 @@ const packageName = packageJson.name ?? "@pocketjs/framework"; const args = process.argv.slice(2); let extraChars = ""; +let regularFontPath: string | undefined; +let boldFontPath: string | undefined; let appArg = ""; let frameworkFlag: string | undefined; let configPath = join(ROOT, "pocket.config.ts"); @@ -84,6 +89,8 @@ let densityFlag: number | undefined; let projectRoot = process.cwd(); for (const a of args) { if (a.startsWith("--extra-chars=")) extraChars = a.slice("--extra-chars=".length); + else if (a.startsWith("--font-regular=")) regularFontPath = resolvePath(a.slice("--font-regular=".length)); + else if (a.startsWith("--font-bold=")) boldFontPath = resolvePath(a.slice("--font-bold=".length)); else if (a.startsWith("--framework=")) frameworkFlag = a.slice("--framework=".length); else if (a.startsWith("--config=")) { configPath = resolvePath(ROOT, a.slice("--config=".length)); configFlagged = true; } else if (a === "--no-config") useConfig = false; @@ -287,6 +294,8 @@ const atlases = await bakeAtlases({ slots: styles.usedFontSlots, extraChars, rasterDensity, + regularTtf: regularFontPath, + boldTtf: boldFontPath, }); for (const a of atlases) { console.log(