[merge] Move renameCFFCharStrings to merge.util

This commit is contained in:
Behdad Esfahbod 2021-12-16 10:24:59 -07:00
parent 8ee5f26731
commit 01fcec35c6
3 changed files with 10 additions and 12 deletions

View File

@ -87,7 +87,7 @@ class Merger(object):
if cffTable: if cffTable:
# Rename CFF CharStrings to match the new glyphOrder. # Rename CFF CharStrings to match the new glyphOrder.
# Using cffTable from before reloading the fonts, because reasons. # Using cffTable from before reloading the fonts, because reasons.
self._renameCFFCharStrings(glyphOrder, cffTable) renameCFFCharStrings(self, glyphOrder, cffTable)
font['CFF '] = cffTable font['CFF '] = cffTable
mega = ttLib.TTFont(sfntVersion=sfntVersion) mega = ttLib.TTFont(sfntVersion=sfntVersion)
@ -129,15 +129,6 @@ class Merger(object):
return mega return mega
def _renameCFFCharStrings(self, glyphOrder, cffTable):
"""Rename topDictIndex charStrings based on glyphOrder."""
td = cffTable.cff.topDictIndex[0]
charStrings = {}
for i, v in enumerate(td.CharStrings.charStrings.values()):
glyphName = glyphOrder[i]
charStrings[glyphName] = v
cffTable.cff.topDictIndex[0].CharStrings.charStrings = charStrings
def mergeObjects(self, returnTable, logic, tables): def mergeObjects(self, returnTable, logic, tables):
# Right now we don't use self at all. Will use in the future # Right now we don't use self at all. Will use in the future
# for options and logging. # for options and logging.
@ -244,7 +235,6 @@ class Merger(object):
markFilteringSetMap = NonhashableDict(GDEF.table.MarkGlyphSetsDef.Coverage) markFilteringSetMap = NonhashableDict(GDEF.table.MarkGlyphSetsDef.Coverage)
t.table.LookupList.mapMarkFilteringSets(markFilteringSetMap) t.table.LookupList.mapMarkFilteringSets(markFilteringSetMap)
# TODO FeatureParams nameIDs # TODO FeatureParams nameIDs

View File

@ -113,4 +113,3 @@ def computeMegaCmap(merger, tables):
# TODO: Try harder to do something about these. # TODO: Try harder to do something about these.
log.warning("Dropped mapping from codepoint %#06X to glyphId '%s'", uni, gid) log.warning("Dropped mapping from codepoint %#06X to glyphId '%s'", uni, gid)

View File

@ -194,3 +194,12 @@ class NonhashableDict(object):
def __delitem__(self, k): def __delitem__(self, k):
del self.d[id(k)] del self.d[id(k)]
def renameCFFCharStrings(merger, glyphOrder, cffTable):
"""Rename topDictIndex charStrings based on glyphOrder."""
td = cffTable.cff.topDictIndex[0]
charStrings = {}
for i, v in enumerate(td.CharStrings.charStrings.values()):
glyphName = glyphOrder[i]
charStrings[glyphName] = v
cffTable.cff.topDictIndex[0].CharStrings.charStrings = charStrings