Change cmap-based duplicate-name resolution from n^2 to linear time
Similar to 85be2e0a9773acec3c6d14c345b1fd94ab3aa5c3, though much harder to hit.
This commit is contained in:
parent
4ff0d4b192
commit
9f23ee4cc8
@ -506,12 +506,11 @@ class TTFont(object):
|
|||||||
# create uni<CODE> name
|
# create uni<CODE> name
|
||||||
glyphName = "uni%04X" % unicode
|
glyphName = "uni%04X" % unicode
|
||||||
tempName = glyphName
|
tempName = glyphName
|
||||||
n = 1
|
n = allNames.get(tempName, 0)
|
||||||
while tempName in allNames:
|
if n:
|
||||||
tempName = glyphName + "#" + repr(n)
|
tempName = glyphName + "#" + str(n)
|
||||||
n = n + 1
|
|
||||||
glyphOrder[i] = tempName
|
glyphOrder[i] = tempName
|
||||||
allNames[tempName] = 1
|
allNames[tempName] = n + 1
|
||||||
# Delete the temporary cmap table from the cache, so it can
|
# Delete the temporary cmap table from the cache, so it can
|
||||||
# be parsed again with the right names.
|
# be parsed again with the right names.
|
||||||
del self.tables['cmap']
|
del self.tables['cmap']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user