Fix application of CV/SS on certain composites and some of the sample images (#1433).

This commit is contained in:
be5invis 2022-10-09 16:29:24 -07:00
parent 45d1f7479b
commit dd69cf9c89
149 changed files with 389 additions and 369 deletions

View file

@ -1,4 +1,4 @@
import [AddCommonFeature AddFeature AddLookup AdeFeatureLookup ChainRuleBuilder BeginLookupBlock EndLookupBlock UkMapToLookup UkMap2ToLookup] from"./table-util.mjs"
import [AddCommonFeature AddFeature AddLookup AddFeatureLookup ChainRuleBuilder BeginLookupBlock EndLookupBlock UkMapToLookup UkMap2ToLookup] from"./table-util.mjs"
import [AnyCv Dotless TieMark TieGlyph CcmpDecompose] from"../support/gr.mjs"
import as UnicodeKnowledge from"../meta/unicode-knowledge.mjs"
@ -221,7 +221,7 @@ export : define [buildCCMP sink glyphStore markGlyphs] : begin
define lookupCcmp-Decompose : AddLookup sink : object
.type 'gsub_multiple'
.substitutions decompositions
AdeFeatureLookup ccmp lookupCcmp-Decompose
AddFeatureLookup ccmp lookupCcmp-Decompose
AddCommonFeature sink ccmp
EndLookupBlock rec sink

View file

@ -1,4 +1,4 @@
import [AddLookup AddCommonFeature PickFeature AdeFeatureLookup PickLookup BeginLookupBlock EndLookupBlock ChainRuleBuilder] from"./table-util.mjs"
import [AddLookup AddCommonFeature PickCommonFeature AddFeatureLookup PickLookup BeginLookupBlock EndLookupBlock ChainRuleBuilder] from"./table-util.mjs"
import [Cv AnyCv CvDecompose RightDependentLink RightDependentTrigger] from"../support/gr.mjs"
extern Map
@ -9,63 +9,80 @@ define-operator "~>" 880 'right' : syntax-rules
`(@l ~> @r) `{.left @l .right @r}
define [FeatureName tag] : tag + '_cvss'
define [CvLookupName tag] : 'lookup_cv_' + tag
define [SsLookupName tag] : 'lookup_ss_' + tag
define [CvLookupName tag] : 'lookup_cv_' + tag
define [CvDecomposeLookupName tag] : 'lookup_cv_decompose_' + tag
export : define [buildCVSS sink para glyphStore] : begin
define {chain-rule} : ChainRuleBuilder sink
local rec : BeginLookupBlock sink
local cvLookupNameSet : new Set
local cvDecompositionLookupNameSet : new Set
local ssLookupNameSet : new Set
# Decomposition of enclosures
define decompositions {.}
foreach { gid g } [glyphStore.namedEntries] : begin
local parts : CvDecompose.get g
if (parts && parts.length) : set decompositions.(gid) parts
define [addCvMapping tag src dst rank] : begin
define feature : PickCommonFeature sink [FeatureName tag]
define lookupName : CvLookupName tag
define lookup : PickLookup sink lookupName {.type 'gsub_alternate' .substitutions {.}}
define lookupNameCvDecompose : AddLookup sink : object
.type 'gsub_multiple'
.substitutions decompositions
if [not : cvLookupNameSet.has lookupName] : begin
AddFeatureLookup feature lookupName
cvLookupNameSet.add lookupName
define [addFeatureAndLookup tag lookupName init] : begin
define feature : PickFeature sink [FeatureName tag]
AddCommonFeature sink feature
if [not lookup.substitutions.(src)] : set lookup.substitutions.(src) { }
set lookup.substitutions.(src).(rank - 1) dst
define lookup : PickLookup sink lookupName init
AdeFeatureLookup feature lookupNameCvDecompose
AdeFeatureLookup feature lookupName
sink.lookupDep.push { lookupNameCvDecompose lookupName }
cvLookupNameSet.add lookupName
define [addCvDecomposition tag gn parts] : begin
define feature : PickCommonFeature sink [FeatureName tag]
define lookupName : CvDecomposeLookupName tag
define lookup : PickLookup sink lookupName {.type 'gsub_multiple' .substitutions {.}}
if [not : cvDecompositionLookupNameSet.has lookupName] : begin
AddFeatureLookup feature lookupName
cvDecompositionLookupNameSet.add lookupName
define lookupNameCv : CvLookupName tag
sink.lookupDep.push { lookupName lookupNameCv }
set lookup.substitutions.(gn) parts
define [addSsSubstitution tag decomp src dst] : begin
define feature : PickCommonFeature sink [FeatureName tag]
define lookupName : SsLookupName composition.tag
define lookup : PickLookup sink lookupName {.type 'gsub_single' .substitutions {.}}
if [not : ssLookupNameSet.has lookupName] : begin
AddFeatureLookup feature lookupName
ssLookupNameSet.add lookupName
foreach { prime pv } [items-of decomp] : if (pv.tag && pv.rank) : begin
local pvDecomp : CvDecomposeLookupName pv.tag
if [cvDecompositionLookupNameSet.has pvDecomp] : begin
AddFeatureLookup feature pvDecomp
sink.lookupDep.push { pvDecomp lookupName }
set lookup.substitutions.(src) dst
# 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
addCvMapping gr.tag gn [glyphStore.ensureExists : gr.get glyph] gr.rank
local st [PickLookup sink lookupName].substitutions
if [not st.(gn)] : set st.(gn) { }
set st.(gn).(gr.rank - 1) : glyphStore.ensureExists : gr.get glyph
foreach {gn glyph} [glyphStore.namedEntries] : if [CvDecompose.get glyph] : do
local parts : CvDecompose.get glyph
foreach part [items-of parts] : begin
local gPart : glyphStore.queryByName part
if gPart : foreach [gr : items-of : AnyCv.query gPart] : if gr.tag : begin
addCvDecomposition gr.tag gn parts
# ssxx
foreach {name composition} para.variants.composites : if composition.tag : do
define lookupName : SsLookupName composition.tag
if [not : ssLookupNameSet.has lookupName] : begin
addFeatureAndLookup composition.tag lookupName {.type 'gsub_single' .substitutions {.}}
cvLookupNameSet.add lookupName
define st [PickLookup sink lookupName].substitutions
define decomp : composition.decompose para para.variants.selectorTree
foreach { prime pv } [items-of decomp] : if (pv.tag && pv.rank) : begin
local gr : Cv pv.tag pv.rank
foreach {gn glyph} [glyphStore.namedEntries] : if [not : CvDecompose.get glyph] : begin
local substituted : gr.get glyph
if substituted : set st.(gn) substituted
if substituted : addSsSubstitution composition.tag decomp gn substituted
# If there are holes in the alternates list, fill them
foreach lutn cvLookupNameSet : begin

View file

@ -883,24 +883,19 @@ define [buildLigationsImpl sink para featureName mappedFeature rankedLookups] :
greaterAndEquiv ~> [just 'greaterArrow']
# [| |] {| |}
do "brack-bar" : if [hasLG 'brack-bar'] : begin
CreateLigationLookup : list
chain-rule
{'bracketLeft'} ~> {'ligExtBracketLeft'}
{'bar'} ~> {'ligBarInsideBracketLeft'}
chain-rule
{'bar'} ~> {'ligBarInsideBracketRight'}
{'bracketRight'} ~> {'ligExtBracketRight'}
do "brace-bar" : if [hasLG 'brace-bar'] : begin
CreateLigationLookup : list
chain-rule
{'braceLeft'} ~> {'ligExtBraceLeft'}
{'bar'} ~> {'ligBarInsideBracketLeft'}
chain-rule
{'bar'} ~> {'ligBarInsideBracketRight'}
{'braceRight'} ~> {'ligExtBraceRight'}
CreateLigationLookup : list
if [hasLG 'brack-bar'] : chain-rule
{'bracketLeft'} ~> {'ligExtBracketLeft'}
{'bar'} ~> {'ligBarInsideBracketLeft'}
if [hasLG 'brack-bar'] : chain-rule
{'bar'} ~> {'ligBarInsideBracketRight'}
{'bracketRight'} ~> {'ligExtBracketRight'}
if [hasLG 'brace-bar'] : chain-rule
{'braceLeft'} ~> {'ligExtBraceLeft'}
{'bar'} ~> {'ligBarInsideBracketLeft'}
if [hasLG 'brace-bar'] : chain-rule
{'bar'} ~> {'ligBarInsideBracketRight'}
{'braceRight'} ~> {'ligExtBraceRight'}
do "Plus chains" : if [hasLG 'plusplus'] : begin
CreateLigationLookup : list

View file

@ -36,7 +36,14 @@ export : define [PickFeature sink name] : begin
set sink.features.(name) featObj.lookups
return featObj
export : define [AdeFeatureLookup fea lookupName] : begin
export : define [PickCommonFeature sink name] : begin
if sink.features.(name) : return { .name name .lookups sink.features.(name) }
define featObj { .name name .lookups {} }
set sink.features.(name) featObj.lookups
AddCommonFeature sink featObj
return featObj
export : define [AddFeatureLookup fea lookupName] : begin
define index : fea.lookups.indexOf lookupName
if (index < 0) : fea.lookups.push lookupName