Support exclusion in supported language derivation

This commit is contained in:
be5invis 2023-04-08 12:09:02 -07:00
parent 0cf321543f
commit c74fc5f4f8

View file

@ -8,14 +8,18 @@ import { gatherCoverageData } from "./coverage-export/gather-coverage-data.mjs";
// List all the languages that Iosevka supports, but cannot inferred from CLDR data. // List all the languages that Iosevka supports, but cannot inferred from CLDR data.
const overrideSupportedLanguages = []; const overrideSupportedLanguages = [];
const excludedSupportedLanguages = new Set(["Hinglish"]);
async function readMpCharMap(p) { async function readMpCharMap(p) {
return decode(zlib.gunzipSync(await fs.promises.readFile(p))); return decode(zlib.gunzipSync(await fs.promises.readFile(p)));
} }
function getSupportedLanguageSet(rawCoverage) { function getSupportedLanguageSet(rawCoverage) {
const supportLocaleSet = getSupportLocaleSet(rawCoverage); const supportLocaleSet = getSupportLocaleSet(rawCoverage);
addSimilarLocales(supportLocaleSet); addSimilarLocales(supportLocaleSet);
return getSupportedLangs(supportLocaleSet); return getSupportedLangs(supportLocaleSet);
} }
function getSupportLocaleSet(rawCoverage) { function getSupportLocaleSet(rawCoverage) {
const supportLocaleSet = new Set(); const supportLocaleSet = new Set();
for (const locale of cldr.localeIds) { for (const locale of cldr.localeIds) {
@ -43,6 +47,7 @@ function getSupportLocaleSet(rawCoverage) {
} }
return supportLocaleSet; return supportLocaleSet;
} }
function addSimilarLocales(supportLocaleSet) { function addSimilarLocales(supportLocaleSet) {
for (const loc of supportLocaleSet) { for (const loc of supportLocaleSet) {
const seg = loc.split("_"); const seg = loc.split("_");
@ -55,6 +60,7 @@ function addSimilarLocales(supportLocaleSet) {
} }
} }
} }
function getSupportedLangs(supportLocaleSet) { function getSupportedLangs(supportLocaleSet) {
const supportLangSet = new Set(overrideSupportedLanguages); const supportLangSet = new Set(overrideSupportedLanguages);
for (const loc of supportLocaleSet) { for (const loc of supportLocaleSet) {
@ -66,16 +72,20 @@ function getSupportedLangs(supportLocaleSet) {
if (subDisplayName) if (subDisplayName)
displayName = subDisplayName + (upperLoc === loc ? "" : "\u00A0(" + loc + ")"); displayName = subDisplayName + (upperLoc === loc ? "" : "\u00A0(" + loc + ")");
} }
if (displayName) supportLangSet.add(displayName); if (displayName && !excludedSupportedLanguages.has(displayName)) {
supportLangSet.add(displayName);
}
} }
return supportLangSet; return supportLangSet;
} }
function getRawCoverage(charMap) { function getRawCoverage(charMap) {
const rawCoverage = new Map(); const rawCoverage = new Map();
for (const [gn, codes, tv, cv] of charMap) for (const [gn, codes, tv, cv] of charMap)
for (const u of codes) rawCoverage.set(u, [gn, tv, cv]); for (const u of codes) rawCoverage.set(u, [gn, tv, cv]);
return rawCoverage; return rawCoverage;
} }
export async function getCharMapAndSupportedLanguageList(cmpUpright, cmpItalic, cmpOblique) { export async function getCharMapAndSupportedLanguageList(cmpUpright, cmpItalic, cmpOblique) {
const charMap = await readMpCharMap(cmpUpright); const charMap = await readMpCharMap(cmpUpright);
const charMapItalic = await readMpCharMap(cmpItalic); const charMapItalic = await readMpCharMap(cmpItalic);