101 lines
3 KiB
Text
101 lines
3 KiB
Text
import as toposort from 'toposort'
|
|
import as Gr from '../support/gr'
|
|
|
|
import [CreateEmptyTable finalizeTable MoveBackUtilityLookups] from "./table-util"
|
|
|
|
import [buildLigations] from './gsub-ligation'
|
|
import [buildCCMP] from './gsub-ccmp'
|
|
import [buildGrFeature] from './gsub-gr'
|
|
import [buildFrac] from './gsub-frac'
|
|
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
|
|
buildGrFeature gsub glyphStore Gr.Lnum
|
|
buildGrFeature gsub glyphStore Gr.Onum
|
|
|
|
# NWID / WWID
|
|
if (!para.forceMonospace || para.spacing > 0) : begin
|
|
buildGrFeature gsub glyphStore Gr.Nwid
|
|
buildGrFeature gsub glyphStore Gr.Wwid
|
|
|
|
# APLF
|
|
buildGrFeature gsub glyphStore Gr.AplForm
|
|
|
|
# numr / dnom
|
|
buildGrFeature gsub glyphStore Gr.NumeratorForm
|
|
buildGrFeature gsub glyphStore Gr.DenominatorForm
|
|
|
|
# ccmp
|
|
buildCCMP gsub glyphStore markGlyphs
|
|
|
|
# frac
|
|
buildFrac gsub glyphStore
|
|
|
|
# Ligation
|
|
if para.enableLigation : do
|
|
define plm : Object.assign {.} 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
|
|
|
|
# Make all diacritics join-l (Kitty #3716)
|
|
foreach gnMark [items-of markGlyphs.all] : begin
|
|
Gr.Joining.or [glyphStore.queryByName gnMark] Gr.Joining.Classes.Left
|
|
|
|
# Build compatibility ligatures
|
|
if (para.enableLigation && para.compLig) : begin
|
|
BuildCompatLigatures para glyphStore GSUB GDEF para.compLig
|
|
|
|
return [object GSUB GPOS GDEF]
|