From a8c0b524651b0a306152a96cd7550d4a7f8b6066 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 21:39:15 -0400 Subject: [PATCH 1/5] 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", From 729376d1c87d04f52581fa612b68500e2f74cac7 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 22:24:37 -0400 Subject: [PATCH 2/5] Update font assignments --- fonts.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fonts.json b/fonts.json index a0e89ef..dc23bb4 100644 --- a/fonts.json +++ b/fonts.json @@ -1,7 +1,5 @@ { "font-families": { - "Gothic A1": ["regular", "700"], - "M PLUS Rounded 1c": ["regular", "700"], "Noto Sans": ["regular", "700", "italic", "700italic"], "Noto Sans Arabic": ["regular", "700"], "Noto Naskh Arabic": ["regular", "700"], @@ -16,8 +14,10 @@ "Noto Sans Gurmukhi": ["regular", "700"], "Noto Sans Hebrew": ["regular", "700"], "Noto Rashi Hebrew": ["regular", "700"], + "M PLUS Rounded 1c": ["regular", "700"], "Noto Sans Kannada": ["regular", "700"], "Noto Sans Khmer": ["regular", "700"], + "Noto Sans KR": ["regular", "700"], "Noto Sans Lao": ["regular", "700"], "Noto Sans Malayalam": ["regular", "700"], "Noto Sans Myanmar": ["regular", "700"], @@ -151,14 +151,6 @@ }, "custom-font-stacks": { "Americana-Regular": [ - { - "file": "GothicA1-regular", - "ranges": ["space", "hangul"] - }, - { - "file": "MPlusRounded1C-regular", - "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] - }, { "file": "NotoSansArabic-regular", "ranges": ["arabic"] @@ -203,6 +195,10 @@ "file": "NotoSansHebrew-regular", "ranges": ["hebrew"] }, + { + "file": "MPlusRounded1C-regular", + "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] + }, { "file": "NotoSansKannada-regular", "ranges": ["kannada"] @@ -211,6 +207,10 @@ "file": "NotoSansKhmer-regular", "ranges": ["khmer"] }, + { + "file": "NotoSansKr-regular", + "ranges": ["space", "hangul"] + }, { "file": "NotoSansLao-regular", "ranges": ["lao"] @@ -266,7 +266,7 @@ ], "Americana-Bold": [ { - "file": "GothicA1-700", + "file": "NotoSansKr-700", "ranges": ["space", "hangul"] }, { @@ -380,7 +380,7 @@ ], "Americana-Italic": [ { - "file": "GothicA1-regular", + "file": "NotoSansKr-regular", "ranges": ["space", "hangul"] }, { @@ -494,7 +494,7 @@ ], "Americana-Bold-Italic": [ { - "file": "GothicA1-700", + "file": "NotoSansKr-700", "ranges": ["space", "hangul"] }, { From b14516110fa04f7d6d82ed3e00e8d4f0a8b9da28 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 22:25:25 -0400 Subject: [PATCH 3/5] Discard code changes --- fonts.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/fonts.js b/fonts.js index ced53f3..6288b3e 100644 --- a/fonts.js +++ b/fonts.js @@ -89,10 +89,6 @@ 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]; @@ -110,27 +106,14 @@ 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: filteredGlyphArray, // Use the filtered array + subset: subsetGlyphArray, hinting: true, compound2simple: true, inflate: null, combinePath: false, }); - if (font === undefined) { font = fontSegment; font.data.name = { @@ -163,8 +146,6 @@ for (const stack in customFontStacks) { console.log(`Built ${ttfFile}`); } -console.log(`..done`); - const pbfBuilderFilename = "~/.cargo/bin/build_pbf_glyphs"; async function buildPbf() { From 452eead10e9d36320dc9c30e371bd4a55c5faa82 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 22:28:38 -0400 Subject: [PATCH 4/5] Remove CJK --- fonts.json | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/fonts.json b/fonts.json index dc23bb4..dbc2b0d 100644 --- a/fonts.json +++ b/fonts.json @@ -14,10 +14,8 @@ "Noto Sans Gurmukhi": ["regular", "700"], "Noto Sans Hebrew": ["regular", "700"], "Noto Rashi Hebrew": ["regular", "700"], - "M PLUS Rounded 1c": ["regular", "700"], "Noto Sans Kannada": ["regular", "700"], "Noto Sans Khmer": ["regular", "700"], - "Noto Sans KR": ["regular", "700"], "Noto Sans Lao": ["regular", "700"], "Noto Sans Malayalam": ["regular", "700"], "Noto Sans Myanmar": ["regular", "700"], @@ -195,10 +193,6 @@ "file": "NotoSansHebrew-regular", "ranges": ["hebrew"] }, - { - "file": "MPlusRounded1C-regular", - "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] - }, { "file": "NotoSansKannada-regular", "ranges": ["kannada"] @@ -207,10 +201,6 @@ "file": "NotoSansKhmer-regular", "ranges": ["khmer"] }, - { - "file": "NotoSansKr-regular", - "ranges": ["space", "hangul"] - }, { "file": "NotoSansLao-regular", "ranges": ["lao"] @@ -269,10 +259,6 @@ "file": "NotoSansKr-700", "ranges": ["space", "hangul"] }, - { - "file": "MPlusRounded1C-700", - "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] - }, { "file": "NotoSansArabic-700", "ranges": ["arabic"] @@ -379,14 +365,6 @@ } ], "Americana-Italic": [ - { - "file": "NotoSansKr-regular", - "ranges": ["space", "hangul"] - }, - { - "file": "MPlusRounded1C-regular", - "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] - }, { "file": "NotoSansArabic-regular", "ranges": ["arabic"] @@ -493,14 +471,6 @@ } ], "Americana-Bold-Italic": [ - { - "file": "NotoSansKr-700", - "ranges": ["space", "hangul"] - }, - { - "file": "MPlusRounded1C-700", - "ranges": ["fullwidth", "hiragana", "kanbun", "katakana"] - }, { "file": "NotoSansArabic-700", "ranges": ["arabic"] From 3ffcc1ebdbc3bd9f5b733293de1273973c687598 Mon Sep 17 00:00:00 2001 From: Brian Sperlongano Date: Fri, 23 Aug 2024 22:29:22 -0400 Subject: [PATCH 5/5] Add space to latin --- fonts.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fonts.json b/fonts.json index dbc2b0d..df3722b 100644 --- a/fonts.json +++ b/fonts.json @@ -251,14 +251,10 @@ }, { "file": "NotoSans-regular", - "ranges": ["cyrillic", "greek", "latin"] + "ranges": ["cyrillic", "greek", "latin", "space"] } ], "Americana-Bold": [ - { - "file": "NotoSansKr-700", - "ranges": ["space", "hangul"] - }, { "file": "NotoSansArabic-700", "ranges": ["arabic"] @@ -361,7 +357,7 @@ }, { "file": "NotoSans-700", - "ranges": ["cyrillic", "greek", "latin"] + "ranges": ["cyrillic", "greek", "latin", "space"] } ], "Americana-Italic": [ @@ -467,7 +463,7 @@ }, { "file": "NotoSans-italic", - "ranges": ["cyrillic", "greek", "latin"] + "ranges": ["cyrillic", "greek", "latin", "space"] } ], "Americana-Bold-Italic": [ @@ -573,7 +569,7 @@ }, { "file": "NotoSans-700italic", - "ranges": ["cyrillic", "greek", "latin"] + "ranges": ["cyrillic", "greek", "latin", "space"] } ] }