From a8c0b524651b0a306152a96cd7550d4a7f8b6066 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 21:39:15 -0400 Subject: [PATCH] Switch to Noto Sans Korean --- fonts.js | 21 ++++++++++++++++++++- package-lock.json | 10 +++++++--- package.json | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/fonts.js b/fonts.js index 6288b3e..ced53f3 100644 --- a/fonts.js +++ b/fonts.js @@ -89,6 +89,10 @@ loadGoogleFonts(bundleFontStacks, bundleFontFolder); copyFolderContents(bundleFontFolder, ttfFontFolder); for (const stack in customFontStacks) { + // Set to track seen unicode codepoints + const seenCodepoints = new Set(); + + console.log(`Building ${stack}`); let font; for (const stackPart in customFontStacks[stack]) { let stackPartDef = customFontStacks[stack][stackPart]; @@ -106,14 +110,27 @@ for (const stack in customFontStacks) { subsetRange[0], subsetRange[1] ); + + // Filter out glyphs that have already been added + const filteredGlyphArray = subsetGlyphArray.filter((codepoint) => { + if (seenCodepoints.has(codepoint)) { + console.log("DUPE"); + return false; + } else { + seenCodepoints.add(codepoint); + return true; + } + }); + const fontSegment = Font.create(inputFontBuffer, { type: "ttf", - subset: subsetGlyphArray, + subset: filteredGlyphArray, // Use the filtered array hinting: true, compound2simple: true, inflate: null, combinePath: false, }); + if (font === undefined) { font = fontSegment; font.data.name = { @@ -146,6 +163,8 @@ for (const stack in customFontStacks) { console.log(`Built ${ttfFile}`); } +console.log(`..done`); + const pbfBuilderFilename = "~/.cargo/bin/build_pbf_glyphs"; async function buildPbf() { diff --git a/package-lock.json b/package-lock.json index 9b93af1..e73c675 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "americana-fonts", "version": "0.1.0", "devDependencies": { - "fonteditor-core": "^2.1.11", + "fonteditor-core": "^2.4.1", "glob": "^9.2.1", "google-font-installer": "^1.2.0", "npm-run-all": "^4.1.5", @@ -305,7 +305,9 @@ } }, "node_modules/fonteditor-core": { - "version": "2.1.11", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/fonteditor-core/-/fonteditor-core-2.4.1.tgz", + "integrity": "sha512-nKDDt6kBQGq665tQO5tCRQUClJG/2MAF9YT1eKHl+I4NasdSb6DgXrv/gMjNxjo9NyaVEv9KU9VZxLHMstN1wg==", "dev": true, "dependencies": { "@xmldom/xmldom": "^0.8.3" @@ -1733,7 +1735,9 @@ "dev": true }, "fonteditor-core": { - "version": "2.1.11", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/fonteditor-core/-/fonteditor-core-2.4.1.tgz", + "integrity": "sha512-nKDDt6kBQGq665tQO5tCRQUClJG/2MAF9YT1eKHl+I4NasdSb6DgXrv/gMjNxjo9NyaVEv9KU9VZxLHMstN1wg==", "dev": true, "requires": { "@xmldom/xmldom": "^0.8.3" diff --git a/package.json b/package.json index 69b5b3c..c97c094 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": {}, "devDependencies": { - "fonteditor-core": "^2.1.11", + "fonteditor-core": "^2.4.1", "glob": "^9.2.1", "google-font-installer": "^1.2.0", "npm-run-all": "^4.1.5",