77 lines
2.3 KiB
Text
77 lines
2.3 KiB
Text
import [AddCommonFeature AddFeature AddLookup] from"./table-util.mjs"
|
|
|
|
extern Map
|
|
extern Set
|
|
|
|
define MarkClasses {
|
|
'above' 'below' 'overlay' 'slash' 'topright' 'bottomright'
|
|
'trailing' 'lf' 'tieAbove' 'tieBelow' 'aboveBrace' 'belowBrace' 'grekUpperTonos'
|
|
'cvDecompose' 'enclosureInner' 'enclosureInnerFirstHalf' 'enclosureInnerSecondHalf'
|
|
'fracBuildUp'
|
|
}
|
|
|
|
export : define [buildMarkMkmk sink glyphStore] : begin
|
|
define validMarkClasses : new Set MarkClasses
|
|
|
|
define mark : object
|
|
feature : AddFeature sink 'mark'
|
|
lookupMap : new Map
|
|
lookupNames : new Set
|
|
createLookup : function [] {.type 'gpos_mark_to_base' .marks {.} .bases {.}}
|
|
define mkmk : object
|
|
feature : AddFeature sink 'mkmk'
|
|
lookupMap : new Map
|
|
lookupNames : new Set
|
|
createLookup : function [] {.type 'gpos_mark_to_mark' .marks {.} .bases {.}}
|
|
|
|
AddCommonFeature sink mark.feature
|
|
AddCommonFeature sink mkmk.feature
|
|
|
|
foreach cls [items-of MarkClasses] : begin
|
|
local markLookup : ensureLookup sink mark cls
|
|
local mkmkLookup : ensureLookup sink mkmk cls
|
|
|
|
foreach { gn glyph } [glyphStore.namedEntries] : begin
|
|
local glyphIsMark false
|
|
if glyph.markAnchors.(cls) : begin
|
|
set glyphIsMark true
|
|
addMarkAnchor markLookup gn cls glyph.markAnchors.(cls)
|
|
addMarkAnchor mkmkLookup gn cls glyph.markAnchors.(cls)
|
|
|
|
if glyph.baseAnchors.(cls) : begin
|
|
local anchor : object
|
|
x glyph.baseAnchors.(cls).x
|
|
y glyph.baseAnchors.(cls).y
|
|
if glyphIsMark
|
|
: then : addBaseAnchor mkmkLookup gn cls glyph.baseAnchors.(cls)
|
|
: else : addBaseAnchor markLookup gn cls glyph.baseAnchors.(cls)
|
|
|
|
foreach lidMark mark.lookupNames : foreach lidMkmk mkmk.lookupNames
|
|
sink.lookupDep.push { lidMark lidMkmk }
|
|
|
|
|
|
define [ensureLookup sink feat cls] : begin
|
|
local existing : feat.lookupMap.get cls
|
|
if existing : return existing
|
|
|
|
local novel : feat.createLookup
|
|
local lid : AddLookup sink novel
|
|
feat.feature.lookups.push lid
|
|
feat.lookupNames.add lid
|
|
feat.lookupMap.set cls novel
|
|
|
|
return novel
|
|
|
|
define [addMarkAnchor lookup gn cls anchor] : begin
|
|
local a : object
|
|
class cls
|
|
x anchor.x
|
|
y anchor.y
|
|
set lookup.marks.(gn) a
|
|
|
|
define [addBaseAnchor lookup gn cls anchor] : begin
|
|
local a : object
|
|
x anchor.x
|
|
y anchor.y
|
|
if [not lookup.bases.(gn)] : set lookup.bases.(gn) {.}
|
|
set lookup.bases.(gn).(cls) a
|