Provide a non-breaking mechanism to add variants. Thus, it is 26.1.0 again (#1904).

This commit is contained in:
be5invis 2023-08-09 15:56:27 -07:00
parent 30a050e307
commit 85494ed45a
6 changed files with 21 additions and 8 deletions

View file

@ -1,4 +1,4 @@
* \[**Breaking**\] Add XH-height middle-serifed and dual-serifed variants for Eszet. As a result, current variants are reordered (#1904).
* Make Cyrillic Abkhasian Che respond to C's serifs (#1898).
* Drop APL form for `U+220D` as it is not used by any APL languages (#1901).
* Add XH-height middle-serifed and dual-serifed variants for Eszet (#1904).
* Fix `cv36`, `cv46`, `cv47`, `cv48`, `cv49`, `cv50`, `cv61`, and `cv74` under Curly Slab.

View file

@ -267,9 +267,17 @@ class VariantBuilder {
globalState.stages.get(this.entry).accept(globalState, localState);
globalState.sink.sort(
(a, b) =>
a.nonBreakingVariantAdditionPriority - b.nonBreakingVariantAdditionPriority ||
a.rank - b.rank
);
let ans = {};
let itemRank = 0;
for (const item of globalState.sink) {
let cfg = item.createPrimeVariant();
cfg.rank = ++itemRank;
if (!cfg.key) throw new Error("Invalid variant key");
if (ans[cfg.key]) throw new Error("Duplicate variant : " + cfg.key);
ans[cfg.key] = cfg;
@ -309,6 +317,7 @@ class VbStageAlternative {
this.key = key;
this.rank = raw.rank;
this.groupRank = raw.groupRank;
this.nonBreakingVariantAdditionPriority = raw.nonBreakingVariantAdditionPriority || 0;
this.next = raw.next;
this.mode = raw.mode;
this.enableIf = raw.enableIf;
@ -340,6 +349,13 @@ class VbStageAlternative {
if (this.groupRank) ans.groupRank += this.evalValue(this.groupRank, localState);
else if (this.stage === globalState.entry) ans.groupRank += this.rank;
// nonBreakingVariantAdditionPriority
if (this.nonBreakingVariantAdditionPriority) {
const p = this.evalValue(this.nonBreakingVariantAdditionPriority, localState);
ans.nonBreakingVariantAdditionPriority += p;
ans.groupRank = p;
}
if (this.keyAffix) ans.addKeyAffix(this.mode, this.evalValue(this.keyAffix, localState));
if (this.descriptionJoiner && this.descriptionAffix) {
ans.addDescription(
@ -416,6 +432,7 @@ class VbLocalState {
this.stage = ".start";
this.rank = 0;
this.groupRank = 0;
this.nonBreakingVariantAdditionPriority = 0;
this.descriptionLeader = "";
this.assignments = new Map();
@ -429,6 +446,7 @@ class VbLocalState {
ans.stage = this.stage;
ans.rank = this.rank;
ans.groupRank = this.groupRank;
ans.nonBreakingVariantAdditionPriority = this.nonBreakingVariantAdditionPriority;
ans.descriptionLeader = this.descriptionLeader;
ans.assignments = new Map(this.assignments);
ans.key = [...this.key];

View file

@ -4093,25 +4093,21 @@ next = "terminal"
[prime.eszet.variants-buildup.stages.body.traditional]
rank = 1
groupRank = 10
descriptionAffix = "traditional, Fraktur-like shape"
selectorAffix.eszet = "traditional"
[prime.eszet.variants-buildup.stages.body.traditional-flat-hook]
rank = 2
groupRank = 20
descriptionAffix = "traditional Fraktur-like shape (containing a flat top hook)"
selectorAffix.eszet = "traditionalFlatHook"
[prime.eszet.variants-buildup.stages.body.sulzbacher]
rank = 3
groupRank = 30
descriptionAffix = "more modern, beta-like shape"
selectorAffix.eszet = "sulzbacher"
[prime.eszet.variants-buildup.stages.body.longs-s-lig]
rank = 4
groupRank = 40
descriptionAffix = "ligature of long-S (`ſ`) and `s`"
selectorAffix.eszet = "longSSLig"
@ -4120,19 +4116,16 @@ next = "serifs"
[prime.eszet.variants-buildup.stages.terminal.non-descending]
rank = 1
groupRank = 1
keyAffix = ""
selectorAffix.eszet = ""
[prime.eszet.variants-buildup.stages.terminal.descending]
rank = 2
groupRank = 2
descriptionAffix = "terminal descends baseline"
selectorAffix.eszet = "descending"
[prime.eszet.variants-buildup.stages.terminal.tailed]
rank = 3
groupRank = 2
descriptionAffix = "terminal containing tail"
selectorAffix.eszet = "tailed"
@ -4149,6 +4142,7 @@ selectorAffix.eszet = "middleSerifed"
[prime.eszet.variants-buildup.stages.serifs.middle-serifed-xh]
rank = 3
nonBreakingVariantAdditionPriority = 1000 # REMOVE IN NEXT MAJOR VERSION CHANGE
enableIf = [{body = "sulzbacher"}, {body = "longs-s-lig"}]
descriptionAffix = "serif at middle at x-height"
selectorAffix.eszet = "middleSerifedXH"
@ -4171,6 +4165,7 @@ enableIf = [
{terminal = "non-descending", body = "longs-s-lig"}
]
rank = 6
nonBreakingVariantAdditionPriority = 2000 # REMOVE IN NEXT MAJOR VERSION CHANGE
descriptionAffix = "serif at middle (x-height) and bottom"
selectorAffix.eszet = "dualSerifedXH"