import 'toposort' as toposort import 'object-assign' as objectAssign import '../support/glyph' as Glyph import '../support/transform' as Transform import [CreateEmptyTable finalizeTable MoveBackUtilityLookups] from "./table-util" import [buildLigations] from './gsub-ligation' import [buildCCMP] from './gsub-ccmp' import [buildPairFeature] from './gsub-pairing' import [buildCVSS] from './gsub-cv-ss' import [buildLOCL] from './gsub-locl' import [buildGsubThousands] from './gsub-thousands' import [buildMarkMkmk] from "./gpos-mark-mkmk" import [BuildCompatLigatures] from './compat-ligature' define GDEF_SIMPLE 1 define GDEF_LIGATURE 2 define GDEF_MARK 3 # GSUB define [buildGSUB para glyphStore markGlyphs] : begin define gsub : CreateEmptyTable # lnum / onum buildPairFeature gsub 'lnum' 'onum' glyphStore true # NWID / WWID if (!para.forceMonospace || para.spacing > 0) : begin buildPairFeature gsub 'NWID' 'WWID' glyphStore true # ccmp buildCCMP gsub glyphStore markGlyphs # Ligation if para.enableLigation : do define plm : objectAssign {.} para.ligation.defaultBuildup if (para.ligation.caltBuildup && para.ligation.caltBuildup.length) : begin set plm.calt para.ligation.caltBuildup buildLigations gsub para plm # THND buildGsubThousands gsub para glyphStore # cv##, ss## buildCVSS gsub para glyphStore # locl # Builds last, but the lookups are added into the beginning of the lookup list buildLOCL gsub para glyphStore MoveBackUtilityLookups gsub finalizeTable gsub return gsub # GPOS define [buildGPOS para glyphStore markGlyphs] : begin define gpos : CreateEmptyTable buildMarkMkmk gpos glyphStore finalizeTable gpos return gpos # GDEF define [buildGDEF para glyphStore markGlyphs] : begin local GDEF {.glyphClassDef {.}} foreach { gn glyph } [glyphStore.namedEntries] : begin set GDEF.glyphClassDef.(gn) : if [[regex '_'].test gn] GDEF_LIGATURE GDEF_SIMPLE if (glyph.markAnchors && [begin [local anchorKeys : Object.keys glyph.markAnchors] anchorKeys.length]) : begin foreach key [items-of anchorKeys] : begin if [not markGlyphs.(key)] : set markGlyphs.(key) {} markGlyphs.(key).push gn markGlyphs.all.push gn set GDEF.glyphClassDef.(gn) GDEF_MARK return GDEF export : define [buildOtl para glyphStore] : begin local markGlyphs {.all {} } local GPOS : buildGPOS para glyphStore markGlyphs local GDEF : buildGDEF para glyphStore markGlyphs local GSUB : buildGSUB para glyphStore markGlyphs # Build compatibility ligatures if (para.enableLigation && para.compLig) : begin BuildCompatLigatures para glyphStore GSUB GDEF para.compLig return [object GSUB GPOS GDEF]