Iosevka/font-src/otl/gsub-pairing.ptl

35 lines
No EOL
1.3 KiB
Text

import [add-common-feature add-feature add-lookup BeginLookupBlock EndLookupBlock] from "./table-util"
# Name-driven feature pairs
export : define [buildPairFeature sink tag1 tag2 glyphs glyphList codedOnly] : begin
local rec : BeginLookupBlock sink
local mapTag2 {.}
local mapTag1 {.}
define reHidden : regex "^\\."
define reTag1 : new RegExp ("\\." + tag1 + "$")
foreach [glyph : items-of glyphList] : begin
if ([reTag1.test glyph.name] && ![reHidden.test glyph.name]) : do
local gnTag2 : glyph.name.replace reTag1 ('.' + tag2)
local glyphTag2 glyphs.(gnTag2)
if (glyphTag2) : begin
if(!codedOnly || glyph.unicode && glyph.unicode.length > 0)
set mapTag2.(glyph.name) gnTag2
if(!codedOnly || glyphTag2.unicode && glyphTag2.unicode.length > 0)
set mapTag1.(gnTag2) glyph.name
if [objectIsNotEmpty mapTag1] : begin
define lookup1 : add-lookup sink {.type 'gsub_single' .subtables {mapTag1}}
define feature1 : add-feature sink tag1
feature1.lookups.push lookup1
add-common-feature sink feature1
if [objectIsNotEmpty mapTag2] : begin
define lookup2 : add-lookup sink {.type 'gsub_single' .subtables {mapTag2}}
define feature2 : add-feature sink tag2
feature2.lookups.push lookup2
add-common-feature sink feature2
EndLookupBlock rec sink
define [objectIsNotEmpty obj] : obj && [Object.keys obj].length