Document CV influences (#2005).
This commit is contained in:
parent
a12e74440f
commit
e7368f16e7
3 changed files with 1019 additions and 0 deletions
|
@ -24,6 +24,7 @@ async function main(argv) {
|
|||
readme = (await processLigSetOt(dirs, 2, g => isLanguageSpecificLigTag(g.tag))).apply(readme);
|
||||
readme = (await processLangList(argv)).apply(readme);
|
||||
readme = (await processPrivateBuildPlans()).apply(readme);
|
||||
readme = (await processCvInfluences(argv)).apply(readme);
|
||||
await fs.promises.writeFile(argv.mdFilePath, readme);
|
||||
}
|
||||
|
||||
|
@ -299,6 +300,88 @@ function isLanguageSpecificLigTag(tag) {
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async function processCvInfluences(argv) {
|
||||
const cl = await getCharMapAndSupportedLanguageList(
|
||||
argv.charMapPath,
|
||||
argv.charMapItalicPath,
|
||||
argv.charMapObliquePath
|
||||
);
|
||||
|
||||
let m = {
|
||||
upright: new Map(),
|
||||
italic: new Map()
|
||||
};
|
||||
|
||||
for (const block of cl.unicodeCoverage) {
|
||||
for (const ch of block.characters) {
|
||||
if (!ch.inFont) continue;
|
||||
addToCvInfluenceMap(cl.featureSeries, m.upright, ch.lch, ch.cvFeatureSetsUpright);
|
||||
addToCvInfluenceMap(cl.featureSeries, m.italic, ch.lch, ch.cvFeatureSetsItalic);
|
||||
}
|
||||
}
|
||||
|
||||
const md = new MdCol("Section-CV-Influences");
|
||||
md.log(`### Upright CV influences`);
|
||||
md.log(``);
|
||||
logCvInfluenceMap(md, m.upright);
|
||||
md.log(``);
|
||||
md.log(`### Italic CV influences`);
|
||||
md.log(``);
|
||||
logCvInfluenceMap(md, m.italic);
|
||||
md.log(``);
|
||||
return md;
|
||||
}
|
||||
|
||||
function addToCvInfluenceMap(featureSeries, m, lch, ids) {
|
||||
if (!ids || !ids.length) return;
|
||||
for (const id of ids) {
|
||||
let fs = featureSeries[id];
|
||||
if (!fs) continue;
|
||||
let s = m.get(fs.name);
|
||||
if (!s) {
|
||||
s = new Set();
|
||||
m.set(fs.name, s);
|
||||
}
|
||||
s.add(lch);
|
||||
}
|
||||
}
|
||||
|
||||
function logCvInfluenceMap(md, m) {
|
||||
let a = Array.from(m).sort((a, b) => a[0].toUpperCase().localeCompare(b[0].toUpperCase()));
|
||||
for (const [tag, chars] of a) {
|
||||
md.log(`- \`${tag}\`:`);
|
||||
md.log(``);
|
||||
md.log(` ` + Array.from(chars).map(formatLch).join(", "));
|
||||
md.log(``);
|
||||
}
|
||||
}
|
||||
|
||||
function formatLch(lch) {
|
||||
return mdEscape(lch) + " (`U+" + lch.toString(16).padStart(4, "0").toUpperCase() + "`)";
|
||||
}
|
||||
|
||||
function mdEscape(lch) {
|
||||
let ch = String.fromCodePoint(lch);
|
||||
if (ch === "\\") return "\\\\";
|
||||
if (ch === "`") return "\\`";
|
||||
if (ch === "*") return "\\*";
|
||||
if (ch === "_") return "\\_";
|
||||
if (ch === "{") return "\\{";
|
||||
if (ch === "}") return "\\}";
|
||||
if (ch === "[") return "\\[";
|
||||
if (ch === "]") return "\\]";
|
||||
if (ch === "(") return "\\(";
|
||||
if (ch === ")") return "\\)";
|
||||
if (ch === "#") return "\\#";
|
||||
if (ch === "+") return "\\+";
|
||||
if (ch === "-") return "\\-";
|
||||
if (ch === ".") return "\\.";
|
||||
if (ch === "!") return "\\!";
|
||||
return ch;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async function processLangList(argv) {
|
||||
const cl = await getCharMapAndSupportedLanguageList(
|
||||
argv.charMapPath,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue