Enforce lookup order of CV/SS

This commit is contained in:
be5invis 2020-11-30 19:36:07 -08:00
parent ca3f0b9396
commit ec1cae38a7

View file

@ -11,6 +11,7 @@ export : define [buildCVSS sink para glyphStore] : begin
local rec : BeginLookupBlock sink local rec : BeginLookupBlock sink
local cvLookupNameSet : new Set local cvLookupNameSet : new Set
local ssLookupNameSet : new Set
# Decomposition of enclosures # Decomposition of enclosures
define decompositions {.} define decompositions {.}
@ -22,36 +23,38 @@ export : define [buildCVSS sink para glyphStore] : begin
.type 'gsub_multiple' .type 'gsub_multiple'
.substitutions decompositions .substitutions decompositions
# cvxx define [addFeatureAndLookup tag lookupName init] : begin
foreach {gn glyph} [glyphStore.namedEntries] : if [not : CvDecompose.get glyph] : do define feature : pick-feature sink [FeatureName tag]
foreach [gr : items-of : AnyCv.query glyph] : if gr.tag : begin
local lookupName : CvLookupName gr.tag
if [not : cvLookupNameSet.has lookupName] : begin
local feature : pick-feature sink [FeatureName gr.tag]
add-common-feature sink feature add-common-feature sink feature
local lookup : pick-lookup sink lookupName define lookup : pick-lookup sink lookupName init
begin {.type 'gsub_alternate' .substitutions {.}}
add-feature-lookup feature lookupNameCvDecompose add-feature-lookup feature lookupNameCvDecompose
add-feature-lookup feature lookupName add-feature-lookup feature lookupName
sink.lookupDep.push { lookupNameCvDecompose lookupName } sink.lookupDep.push { lookupNameCvDecompose lookupName }
cvLookupNameSet.add lookupName cvLookupNameSet.add lookupName
# cvxx
foreach {gn glyph} [glyphStore.namedEntries] : if [not : CvDecompose.get glyph] : do
foreach [gr : items-of : AnyCv.query glyph] : if gr.tag : begin
define lookupName : CvLookupName gr.tag
if [not : cvLookupNameSet.has lookupName] : begin
addFeatureAndLookup gr.tag lookupName {.type 'gsub_alternate' .substitutions {.}}
cvLookupNameSet.add lookupName
local st [pick-lookup sink lookupName].substitutions local st [pick-lookup sink lookupName].substitutions
if [not st.(gn)] : set st.(gn) { } if [not st.(gn)] : set st.(gn) { }
set st.(gn).(gr.rank - 1) : glyphStore.ensureExists : gr.get glyph set st.(gn).(gr.rank - 1) : glyphStore.ensureExists : gr.get glyph
# ssxx # ssxx
foreach {name composition} para.variants.composites : if composition.tag : do foreach {name composition} para.variants.composites : if composition.tag : do
local feature : pick-feature sink [FeatureName composition.tag] define lookupName : SsLookupName composition.tag
add-common-feature sink feature if [not : ssLookupNameSet.has lookupName] : begin
add-feature-lookup feature lookupNameCvDecompose addFeatureAndLookup composition.tag lookupName {.type 'gsub_single' .substitutions {.}}
local lookupNameSub : add-lookup sink {.type 'gsub_single' .substitutions {.}} cvLookupNameSet.add lookupName
sink.lookupDep.push { lookupNameCvDecompose lookupNameSub }
add-feature-lookup feature lookupNameSub
define st [pick-lookup sink lookupNameSub].substitutions define st [pick-lookup sink lookupName].substitutions
local decomp : composition.decompose para para.variants.selectorTree define decomp : composition.decompose para para.variants.selectorTree
foreach { prime pv } [items-of decomp] : if (pv.tag && pv.rank) : begin foreach { prime pv } [items-of decomp] : if (pv.tag && pv.rank) : begin
local gr : Cv pv.tag pv.rank local gr : Cv pv.tag pv.rank
foreach {gn glyph} [glyphStore.namedEntries] : if [not : CvDecompose.get glyph] : begin foreach {gn glyph} [glyphStore.namedEntries] : if [not : CvDecompose.get glyph] : begin
@ -64,4 +67,8 @@ export : define [buildCVSS sink para glyphStore] : begin
foreach { k v } [pairs-of st] : foreach idx [range 0 v.length] : if [not v.(idx)] foreach { k v } [pairs-of st] : foreach idx [range 0 v.length] : if [not v.(idx)]
set v.(idx) k set v.(idx) k
# Lookup dependency
foreach lutnCv cvLookupNameSet : foreach lutnSS ssLookupNameSet : begin
sink.lookupDep.push { lutnCv lutnSS }
EndLookupBlock rec sink EndLookupBlock rec sink