Ligation breakdown for C-likes 1 (#1555)
This commit is contained in:
parent
5d594676de
commit
d3b8e339a2
9 changed files with 1132 additions and 843 deletions
|
@ -4,6 +4,8 @@ import url from "url";
|
|||
|
||||
import * as toml from "@iarna/toml";
|
||||
|
||||
import { createBuildup } from "../../font-src/support/ligation-data.mjs";
|
||||
|
||||
const ligationSamplesNarrow = [
|
||||
[
|
||||
"-<<",
|
||||
|
@ -58,8 +60,8 @@ const ligationSamplesNarrow = [
|
|||
[
|
||||
"<:",
|
||||
":=",
|
||||
":-",
|
||||
":+",
|
||||
"*=",
|
||||
"*+",
|
||||
"<*",
|
||||
"<*>",
|
||||
"*>",
|
||||
|
@ -69,8 +71,8 @@ const ligationSamplesNarrow = [
|
|||
"<.",
|
||||
"<.>",
|
||||
".>",
|
||||
"+:",
|
||||
"-:",
|
||||
"+*",
|
||||
"=*",
|
||||
"=:",
|
||||
":>"
|
||||
],
|
||||
|
@ -93,6 +95,7 @@ const ligationSamplesNarrow = [
|
|||
"<!---"
|
||||
]
|
||||
];
|
||||
|
||||
function buildLigationSet(ligData, getKey) {
|
||||
const ligationSets = new Map([
|
||||
["*off", { tag: "calt", rank: 0, desc: "Ligation Off", brief: "Off", ligSets: [] }]
|
||||
|
@ -103,15 +106,12 @@ function buildLigationSet(ligData, getKey) {
|
|||
const key = getKey(comp);
|
||||
let item = ligationSets.get(key);
|
||||
if (!item) {
|
||||
let ligSets = new Set();
|
||||
for (const s of comp.buildup) {
|
||||
ligSets.add(ligData.simple[s].ligGroup);
|
||||
}
|
||||
let ligSets = createBuildup(ligData.simple, ligData.composite, comp.buildup);
|
||||
item = {
|
||||
selector: sel,
|
||||
tag: comp.tag,
|
||||
rank: 1,
|
||||
ligSets: [...ligSets],
|
||||
ligSets,
|
||||
tagName: [comp.tag],
|
||||
desc: comp.desc,
|
||||
brief: comp.brief || comp.desc
|
||||
|
@ -125,6 +125,7 @@ function buildLigationSet(ligData, getKey) {
|
|||
}
|
||||
return ligationSets;
|
||||
}
|
||||
|
||||
export async function parseLigationData() {
|
||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||
const ligToml = await fs.promises.readFile(
|
||||
|
|
|
@ -4,13 +4,25 @@ function* makeSample(theme, args) {
|
|||
const groupSet = new Set(args.ligSets);
|
||||
for (const row of args.ligationSamples) {
|
||||
for (const sampleStr of row) {
|
||||
let rank = 0;
|
||||
let sat = [];
|
||||
|
||||
for (const [lgName, lg] of Object.entries(args.ligationCherry)) {
|
||||
if (!groupSet.has(lg.ligGroup)) continue;
|
||||
if (!new Set(lg.samples || []).has(sampleStr)) continue;
|
||||
const rankT = lg.sampleRank || 1;
|
||||
if (rankT > rank) rank = rankT;
|
||||
|
||||
if (!sat[rankT]) {
|
||||
sat[rankT] = { required: 1, satisfied: 0 };
|
||||
} else {
|
||||
sat[rankT].required += 1;
|
||||
}
|
||||
if (groupSet.has(lg.ligGroup)) {
|
||||
sat[rankT].satisfied += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let rank = sat.length - 1;
|
||||
for (; rank >= 1 && (!sat[rank] || sat[rank].satisfied < sat[rank].required); rank--);
|
||||
|
||||
yield [{ color: theme[rank > 1 ? "stress" : rank > 0 ? "body" : "dimmed"] }, sampleStr];
|
||||
yield " ";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue