Files
Iosevka/otl/gpos-mark-mkmk.ptl
T
2020-03-13 22:17:28 -07:00

55 lines
2.1 KiB
Plaintext

import [add-common-feature add-feature add-lookup] from "./table-util"
define [createBaseInfo g th px py] : begin
local res {.}
local pushed false
foreach key [items-of : Object.keys g.anchors] : if (!th || th.(key)) : begin
set res.(key) : object
.x g.anchors.(key).(px || 'x')
.y g.anchors.(key).(py || 'y')
set pushed true
return : if pushed res nothing
define [createMTLookup glyphList lookupType anchorClasses] : begin
local subtable {.marks {.} .bases {.}}
local th {.}
foreach [ac : items-of anchorClasses] : set th.(ac) true
foreach glyph [items-of glyphList] : if glyph.anchors : begin
local anchorKeys : Object.keys glyph.anchors
local hasAnchor false
foreach [key : items-of anchorKeys] : if th.(key) : set hasAnchor true
if hasAnchor : begin
local isMarkGlyph false
local markKey nothing
foreach key [items-of anchorKeys] : if (glyph.anchors.(key).type == 'mark') : begin
set isMarkGlyph true
set markKey key
if isMarkGlyph
: then : begin
set subtable.marks.(glyph.name) : object
class markKey
x glyph.anchors.(markKey).x
y glyph.anchors.(markKey).y
if (lookupType == 'gpos_mark_to_mark'): begin
local r : createBaseInfo glyph th 'mbx' 'mby'
if r : set subtable.bases.(glyph.name) r
: else : if (lookupType == 'gpos_mark_to_base') : begin
local r : createBaseInfo glyph th 'x' 'y'
if r : set subtable.bases.(glyph.name) r
return {.type lookupType .subtables {subtable}}
export : define [buildMarkMkmk sink glyphList] : begin
define mark : add-feature sink 'mark'
define mkmk : add-feature sink 'mkmk'
add-common-feature sink mark
add-common-feature sink mkmk
local markLookupNames {}
local mkmkLookupNames {}
foreach [marktag : items-of {'above' 'below' 'overlay' 'slash' 'topright' 'bottomright' 'trailing' 'lf'}] : begin
define lookupNameMark : 'lookup_mark_' + marktag
define lookupNameMkmk : 'lookup_mkmk_' + marktag
mark.lookups.push : add-lookup sink : createMTLookup glyphList 'gpos_mark_to_base' {marktag}
mkmk.lookups.push : add-lookup sink : createMTLookup glyphList 'gpos_mark_to_mark' {marktag}