Disunified the variant selector for Greek Delta and Greek Lambda, and added selectable serif variants for Lambda (#1866).

This commit is contained in:
be5invis 2023-07-23 12:51:10 -07:00
parent 8f6cef86fc
commit 764c489f6b
5 changed files with 290 additions and 174 deletions

View file

@ -1,2 +1,3 @@
* \[**Breaking**\] Drop `tailed-top-left-serifed` variant of `n` as it duplicates with `tailed-motion-serifed` (#1859).
* \[**Breaking**\] Disunified the variant selector for Greek Delta and Greek Lambda, and added selectable serif variants for Lambda (#1866).
* Drop `<=` and `>=` as inequality for Verilog (#1864).

View file

@ -18,7 +18,7 @@ glyph-block Letter-Cyrillic-SmallYus : begin
fBarStraight -- straightBar
top -- top
sw -- fine
slab -- false
slabKind -- 0
include : intersection
HBar.t df.leftSB df.rightSB (top / 2) fine
AMaskShape df straightBar top fine
@ -76,10 +76,10 @@ glyph-block Letter-Cyrillic-SmallYus : begin
create-forked-glyph 'cyrl/smallYusClosed.straight' : CyrClosedSmallYusShape df XH true
create-forked-glyph 'cyrl/smallYusClosed.curly' : CyrClosedSmallYusShape df XH false
select-variant 'cyrl/SmallYus' 0x466 (follow -- 'grek/Lambda')
select-variant 'cyrl/smallYus' 0x467 (follow -- 'grek/Lambda')
select-variant 'cyrl/SmallYusClosed' 0xA658 (follow -- 'grek/Lambda')
select-variant 'cyrl/smallYusClosed' 0xA659 (follow -- 'grek/Lambda')
select-variant 'cyrl/SmallYus' 0x466 (follow -- 'cyrl/Yus')
select-variant 'cyrl/smallYus' 0x467 (follow -- 'cyrl/Yus')
select-variant 'cyrl/SmallYusClosed' 0xA658 (follow -- 'grek/Delta')
select-variant 'cyrl/smallYusClosed' 0xA659 (follow -- 'grek/Delta')
define [CyrIotifiedSmallYusShape fClosed fCapital df top straightBar] : glyph-proc
local gap : (df.width - 2 * df.leftSB - 4 * df.mvs) / 3
@ -137,7 +137,7 @@ glyph-block Letter-Cyrillic-SmallYus : begin
create-forked-glyph 'cyrl/smallYusClosedIotified.curly'
CyrIotifiedSmallYusShape true false df XH false
select-variant 'cyrl/SmallYusIotified' 0x468 (follow -- 'grek/Lambda')
select-variant 'cyrl/smallYusIotified' 0x469 (follow -- 'grek/Lambda')
select-variant 'cyrl/SmallYusClosedIotified' 0xA65C (follow -- 'grek/Lambda')
select-variant 'cyrl/smallYusClosedIotified' 0xA65D (follow -- 'grek/Lambda')
select-variant 'cyrl/SmallYusIotified' 0x468 (follow -- 'cyrl/Yus')
select-variant 'cyrl/smallYusIotified' 0x469 (follow -- 'cyrl/Yus')
select-variant 'cyrl/SmallYusClosedIotified' 0xA65C (follow -- 'grek/Delta')
select-variant 'cyrl/smallYusClosedIotified' 0xA65D (follow -- 'grek/Delta')

View file

@ -56,6 +56,12 @@ glyph-block Letter-Latin-Upper-A : begin
intersection [HBar.t 0 df.width yBar] [AMaskShape df fStraightBar top sw]
include : ASerifs df top sw slabKind
glyph-block-export LambdaShape
define [LambdaShape] : with-params [df fBarStraight top sw slabKind] : glyph-proc
include : VShape df fBarStraight top sw
include : FlipAround df.middle (top / 2)
include : ASerifs df top sw slabKind
foreach { suffix { fStraightBar slabKind } } [Object.entries AConfig] : do
define [AShapeImpl mak top fGrek fOverlays] : glyph-proc
local df : DivFrame 1
@ -83,6 +89,24 @@ glyph-block Letter-Latin-Upper-A : begin
create-glyph "currency/australSign.\(suffix)" : AShapeImpl "capital" CAP false true
create-glyph "grek/Lambda.\(suffix)" : glyph-proc
include : MarkSet.capital
include : LambdaShape
df -- [DivFrame 1]
fBarStraight -- fStraightBar
top -- CAP
sw -- Stroke
slabKind -- slabKind
create-glyph "grek/smcpLambda.\(suffix)" : glyph-proc
include : MarkSet.e
include : LambdaShape
df -- [DivFrame 1]
fBarStraight -- fStraightBar
top -- XH
sw -- Stroke
slabKind -- slabKind
select-variant 'A' 'A'
link-reduced-variant 'A/sansSerif' 'A' MathSansSerif
select-variant 'smcpA' 0x1D00 (follow -- 'A')
@ -92,26 +116,9 @@ glyph-block Letter-Latin-Upper-A : begin
alias 'cyrl/A' 0x410 'A'
turned 'turnA' 0x2C6F 'A' Middle (CAP / 2)
# Lambda
glyph-block-export LambdaShape
define [LambdaShape] : with-params [df fBarStraight top sw [slab SLAB]] : glyph-proc
include : VShape df fBarStraight top sw
include : FlipAround df.middle (top / 2)
local sf : SerifFrame.fromDf df top 0
include : NeedSlab slab : composite-proc sf.lb.full sf.rb.full
create-glyph 'grek/Lambda.straight' : composite-proc [MarkSet.capital]
LambdaShape [DivFrame 1] true CAP Stroke
create-glyph 'grek/Lambda.curly' : composite-proc [MarkSet.capital]
LambdaShape [DivFrame 1] false CAP Stroke
create-glyph 'grek/smcpLambda.straight' : composite-proc [MarkSet.e]
LambdaShape [DivFrame 1] true XH Stroke
create-glyph 'grek/smcpLambda.curly' : composite-proc [MarkSet.e]
LambdaShape [DivFrame 1] false XH Stroke
select-variant 'grek/Lambda' 0x39B
link-reduced-variant 'grek/Lambda/sansSerif' 'grek/Lambda' MathSansSerif
select-variant 'grek/smcpLambda' 0x1D27 (follow -- 'grek/Lambda')
alias 'latinLambda' 0x245 'grek/Lambda'
# Delta
glyph-block-export DeltaShape

View file

@ -29,8 +29,9 @@ export function apply(data, para, argv) {
export function parse(data, argv) {
const primes = new Map();
const selectorTree = new SelectorTree();
const ta = new CvTagAllocator();
for (const k in data.prime) {
const p = new Prime(k, data.prime[k]);
const p = new Prime(k, data.prime[k], ta);
p.register(selectorTree);
primes.set(k, p);
}
@ -67,8 +68,53 @@ class SelectorTree {
}
}
class CvTagAllocator {
constructor() {
this.cvCount = 1;
this.kindWiseCount = new Map();
}
createTag(kind) {
if (this.cvCount <= 99) {
return `cv${String(this.cvCount++).padStart(2, "0")}`;
} else {
let n = this.kindWiseCount.get(kind) || 0;
this.kindWiseCount.set(kind, ++n);
return `${this.mapKindToTag(kind)}${this.mapNumberToLetter(n - 1)}`;
}
}
mapKindToTag(kind) {
switch (kind) {
case "letter":
return "VA";
case "digit":
return "VN";
case "dot":
return "VD";
case "symbol":
return "VS";
case "ligature":
return "VL";
}
}
// map number from 0 1 2 3 ... to AA AB AC ...
// 0 => AA, 1 => AB, ... 25 => BA, 26 => BB, ...
// Result should be at least 2 characters
mapNumberToLetter(n) {
let ans = "";
do {
ans += String.fromCharCode((n % 26) + 0x41);
n = Math.floor(n / 26);
} while (n > 0);
while (ans.length < 2) ans = "A" + ans;
return ans;
}
}
class Prime {
constructor(key, cfg) {
constructor(key, cfg, ta) {
this.key = key;
this.sampler = cfg.sampler;
this.samplerExplain = cfg.samplerExplain;
@ -78,7 +124,7 @@ class Prime {
this.descSampleText = this.ligatureSampler
? cfg.sampler.split(" ").filter(x => !!x.trim())
: [...(cfg.sampler || "")];
this.tag = cfg.tag;
if (cfg.tagKind) this.tag = ta.createTag(cfg.tagKind);
this.slopeDependent = !!cfg.slopeDependent;
this.hotChars = cfg.hotChars ? [...cfg.hotChars] : this.descSampleText;
@ -92,7 +138,7 @@ class Prime {
if (!variantConfig) throw new Error(`Missing variants in ${key}`);
for (const varKey in variantConfig) {
const variant = variantConfig[varKey];
this.variants.set(varKey, new PrimeVariant(varKey, cfg.tag, variant));
this.variants.set(varKey, new PrimeVariant(varKey, this.tag, variant));
}
}
register(tree) {

File diff suppressed because it is too large Load diff