[merge] Handle duplicate glyph names better
Instead of appending font index to all glyph names and still potentially have duplicates, use similar code like we use and “post” and “CFF” tables to handle duplicate glyph names.
This commit is contained in:
parent
7cb8e01eda
commit
af42fc24b7
@ -1012,16 +1012,18 @@ class Merger(object):
|
|||||||
def _mergeGlyphOrders(self, glyphOrders):
|
def _mergeGlyphOrders(self, glyphOrders):
|
||||||
"""Modifies passed-in glyphOrders to reflect new glyph names.
|
"""Modifies passed-in glyphOrders to reflect new glyph names.
|
||||||
Returns glyphOrder for the merged font."""
|
Returns glyphOrder for the merged font."""
|
||||||
# Simply append font index to the glyph name for now.
|
mega = {}
|
||||||
# TODO Even this simplistic numbering can result in conflicts.
|
for glyphOrder in glyphOrders:
|
||||||
# But then again, we have to improve this soon anyway.
|
|
||||||
mega = []
|
|
||||||
for n,glyphOrder in enumerate(glyphOrders):
|
|
||||||
for i,glyphName in enumerate(glyphOrder):
|
for i,glyphName in enumerate(glyphOrder):
|
||||||
|
if glyphName in mega:
|
||||||
|
n = mega[glyphName]
|
||||||
|
while (glyphName + "#" + repr(n)) in mega:
|
||||||
|
n += 1
|
||||||
|
mega[glyphName] = n
|
||||||
glyphName += "#" + repr(n)
|
glyphName += "#" + repr(n)
|
||||||
glyphOrder[i] = glyphName
|
glyphOrder[i] = glyphName
|
||||||
mega.append(glyphName)
|
mega[glyphName] = 1
|
||||||
return mega
|
return list(mega.keys())
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user