Skip to content

Commit

Permalink
[merge] Merge GDEF marksets in Lookups properly
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Dec 15, 2021
1 parent ed07df3 commit b8615f9
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Lib/fontTools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,17 @@ def mapLookups(self, lookupMap):
if not l: continue
l.mapLookups(lookupMap)

@_add_method(otTables.Lookup)
def mapMarkFilteringSets(self, markFilteringSetMap):
if self.LookupFlag & 0x0010:
self.MarkFilteringSet = markFilteringSetMap[self.MarkFilteringSet]

@_add_method(otTables.LookupList)
def mapMarkFilteringSets(self, markFilteringSetMap):
for l in self.Lookup:
if not l: continue
l.mapMarkFilteringSets(markFilteringSetMap)

@_add_method(otTables.Feature)
def mapLookups(self, lookupMap):
self.LookupListIndex = [lookupMap[i] for i in self.LookupListIndex]
Expand Down Expand Up @@ -1173,11 +1184,14 @@ def _preMerge(self, font):
t.table.LookupList.mapLookups(lookupMap)
t.table.FeatureList.mapLookups(lookupMap)

if GDEF and GDEF.table.Version >= 0x00010002:
markFilteringSetMap = {i:v for i,v in enumerate(GDEF.table.MarkGlyphSetsDef.Coverage)}
t.table.LookupList.mapMarkFilteringSets(markFilteringSetMap)

if t.table.FeatureList and t.table.ScriptList:
featureMap = {i:v for i,v in enumerate(t.table.FeatureList.FeatureRecord)}
t.table.ScriptList.mapFeatures(featureMap)

# TODO GDEF/Lookup MarkFilteringSets
# TODO FeatureParams nameIDs

def _postMerge(self, font):
Expand Down Expand Up @@ -1234,7 +1248,11 @@ def _postMerge(self, font):

t.table.LookupList.LookupCount = len(t.table.LookupList.Lookup)

# TODO GDEF/Lookup MarkFilteringSets
if GDEF and GDEF.table.Version >= 0x00010002:
markFilteringSetMap = _NonhashableDict(GDEF.table.MarkGlyphSetsDef.Coverage)
t.table.LookupList.mapMarkFilteringSets(markFilteringSetMap)


# TODO FeatureParams nameIDs


Expand Down

0 comments on commit b8615f9

Please sign in to comment.