22 lines
827 B
Text
22 lines
827 B
Text
import [AddCommonFeature AddFeature AddLookup BeginLookupBlock EndLookupBlock] from"./table-util.mjs"
|
|
|
|
# Name-driven feature pairs
|
|
export : define [buildGrFeature sink glyphStore gr] : begin
|
|
local rec : BeginLookupBlock sink
|
|
|
|
local mapping {.}
|
|
foreach { gnSrc glyph } [glyphStore.namedEntries] : begin
|
|
local gnDst : gr.get glyph
|
|
local glyphDst : glyphStore.queryByName gnDst
|
|
if (glyphDst && ([glyphStore.queryUnicodeOf glyph] || [glyphStore.queryUnicodeOf glyphDst]))
|
|
set mapping.(gnSrc) gnDst
|
|
|
|
if [objectIsNotEmpty mapping] : begin
|
|
define lookup1 : AddLookup sink {.type 'gsub_single' .substitutions mapping}
|
|
define feature1 : AddFeature sink gr.otlTag
|
|
feature1.lookups.push lookup1
|
|
AddCommonFeature sink feature1
|
|
|
|
EndLookupBlock rec sink
|
|
|
|
define [objectIsNotEmpty obj] : obj && [Object.keys obj].length
|