From 5147973814670ea86e0501e55a04fea7b39ecafe Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Wed, 19 Nov 2025 08:22:52 -0800 Subject: [PATCH] Fix: Patch opentype.js to support method chaining --- scripts/build-font.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/build-font.js b/scripts/build-font.js index 447db82..6a57181 100644 --- a/scripts/build-font.js +++ b/scripts/build-font.js @@ -33,6 +33,12 @@ const __filename = fileURLToPath(import.meta.url); const outDir = path.join(path.dirname(__filename), "..", "dist"); if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true }); +// Polyfill: opentype.js Path methods return undefined, preventing chaining. Patching to return this. +["moveTo","lineTo","curveTo","quadraticCurveTo","close"].forEach(m=>{ + const f=opentype.Path.prototype[m]; + opentype.Path.prototype[m]=function(...a){f.apply(this,a);return this}; +}); + const mkGlyph = (n, u, a, fn) => new opentype.Glyph({ name: n, unicode: u, advanceWidth: a, path: fn(new opentype.Path()) }); // Candara-ish tracking: wider capitals, tighter lower, distinct narrow/wide glyphs