diff --git a/scripts/build-font.js b/scripts/build-font.js index c47eadd..4cda4fe 100644 --- a/scripts/build-font.js +++ b/scripts/build-font.js @@ -20,13 +20,13 @@ import { glyphO, glypho } from "../src/glyphs/O.js"; import { glyphP, glyphp } from "../src/glyphs/P.js"; import { glyphQ, glyphq } from "../src/glyphs/Q.js"; import { glyphR, glyphr } from "../src/glyphs/R.js"; -import { glyphS, glyphs } from "../src/glyphs/S.js"; +import { glyphS, glyphs as glyphsLowerS } from "../src/glyphs/S.js"; import { glyphT, glypht } from "../src/glyphs/T.js"; import { glyphU, glyphu } from "../src/glyphs/U.js"; import { glyphV, glyphv } from "../src/glyphs/V.js"; import { glyphW, glyphw } from "../src/glyphs/W.js"; import { glyphX, glyphx } from "../src/glyphs/X.js"; -import { glyphY, glyphy } from "../src/glyphs/Y.js"; +import { glyphY, glypthy as glyphy } from "../src/glyphs/Y.js"; import { glyphZ, glyphz } from "../src/glyphs/Z.js"; const __filename = fileURLToPath(import.meta.url); @@ -39,61 +39,61 @@ const familyName = "Stain"; const unitsPerEm = 1000; const ascender = 800; const descender = -200; -const advanceWidth = 600; +const defaultAdv = 600; -const glyphs = [ - glyphA(opentype, advanceWidth), - glypha(opentype, advanceWidth), - glyphB(opentype, advanceWidth), - glyphb(opentype, advanceWidth), - glyphC(opentype, advanceWidth), - glyphc(opentype, advanceWidth), - glyphD(opentype, advanceWidth), - glyphd(opentype, advanceWidth), - glyphE(opentype, advanceWidth), - glyphe(opentype, advanceWidth), - glyphF(opentype, advanceWidth), - glyphf(opentype, advanceWidth), - glyphG(opentype, advanceWidth), - glyphg(opentype, advanceWidth), - glyphH(opentype, advanceWidth), - glyphh(opentype, advanceWidth), - glyphI(opentype, advanceWidth), - glyphi(opentype, advanceWidth), - glyphJ(opentype, advanceWidth), - glyphj(opentype, advanceWidth), - glyphK(opentype, advanceWidth), - glyphk(opentype, advanceWidth), - glyphL(opentype, advanceWidth), - glyphl(opentype, advanceWidth), +const glyphList = [ + glyphA(opentype, defaultAdv), + glypha(opentype, defaultAdv), + glyphB(opentype, defaultAdv), + glyphb(opentype, defaultAdv), + glyphC(opentype, defaultAdv), + glyphc(opentype, defaultAdv), + glyphD(opentype, defaultAdv), + glyphd(opentype, defaultAdv), + glyphE(opentype, defaultAdv), + glyphe(opentype, defaultAdv), + glyphF(opentype, defaultAdv), + glyphf(opentype, defaultAdv), + glyphG(opentype, defaultAdv), + glyphg(opentype, defaultAdv), + glyphH(opentype, defaultAdv), + glyphh(opentype, defaultAdv), + glyphI(opentype, defaultAdv), + glyphi(opentype, defaultAdv), + glyphJ(opentype, defaultAdv), + glyphj(opentype, defaultAdv), + glyphK(opentype, defaultAdv), + glyphk(opentype, defaultAdv), + glyphL(opentype, defaultAdv), + glyphl(opentype, defaultAdv), glyphM(opentype, 740), glyphm(opentype, 740), - glyphN(opentype, advanceWidth), - glyphn(opentype, advanceWidth), - glyphO(opentype, advanceWidth), - glypho(opentype, advanceWidth), - glyphP(opentype, advanceWidth), - glyphp(opentype, advanceWidth), - glyphQ(opentype, advanceWidth), - glyphq(opentype, advanceWidth), - glyphR(opentype, advanceWidth), - glyphr(opentype, advanceWidth), - glyphS(opentype, advanceWidth), - glyphs(opentype, advanceWidth), - glyphT(opentype, advanceWidth), - glypht(opentype, advanceWidth), - glyphU(opentype, advanceWidth), - glyphu(opentype, advanceWidth), - glyphV(opentype, advanceWidth), - glyphv(opentype, advanceWidth), + glyphN(opentype, defaultAdv), + glyphn(opentype, defaultAdv), + glyphO(opentype, defaultAdv), + glypho(opentype, defaultAdv), + glyphP(opentype, defaultAdv), + glyphp(opentype, defaultAdv), + glyphQ(opentype, defaultAdv), + glyphq(opentype, defaultAdv), + glyphR(opentype, defaultAdv), + glyphr(opentype, defaultAdv), + glyphS(opentype, defaultAdv), + glyphsLowerS(opentype, defaultAdv), + glyphT(opentype, defaultAdv), + glypht(opentype, defaultAdv), + glyphU(opentype, defaultAdv), + glyphu(opentype, defaultAdv), + glyphV(opentype, defaultAdv), + glyphv(opentype, defaultAdv), glyphW(opentype, 760), glyphw(opentype, 660), - glyphX(opentype, advanceWidth), - glyphx(opentype, advanceWidth), - glyphY(opentype, advanceWidth), - glypthy(opentype, advanceWidth), - glyphZ(opentype, advanceWidth), - glyphz(opentype, advanceWidth) + glyphX(opentype, defaultAdv), + glyphx(opentype, defaultAdv), + glyphY(opentype, defaultAdv), + glyphy(opentype, defaultAdv), + glyphZ(opentype, defaultAdv), + glyphz(opentype, defaultAdv) ]; const font = new opentype.Font({ @@ -102,12 +102,10 @@ const font = new opentype.Font({ unitsPerEm, ascender, descender, - glyphs + glyphs: glyphList }); -const otfBuffer = Buffer.from(font.toArrayBuffer()); -const baseName = "Stain"; -const otfPath = path.join(outDir, `${baseName}.otf`); -fs.writeFileSync(otfPath, otfBuffer); - -console.log(`Built ${otfPath}`); +const buf = Buffer.from(font.toArrayBuffer()); +const outPath = path.join(outDir, "Stain.otf"); +fs.writeFileSync(outPath, buf); +console.log(`Built ${outPath}`);