From 4ff0d4b19261f9cdb1d6f5f8174c2597ca29acc2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 2 Jun 2014 18:03:35 -0400 Subject: [PATCH] Fix post table glyph name dedup logic for edge case This is a followup fix to 85be2e0a9773acec3c6d14c345b1fd94ab3aa5c3 Before this change, if some glyph names had a "#-number" suffix in the post table, we could generate duplicate glyph names. Fix that, even though "#" is NOT a valid character in PS glyph names. --- Lib/fontTools/ttLib/tables/_p_o_s_t.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py index 248983fcf..8181e1f3d 100644 --- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py +++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py @@ -113,12 +113,13 @@ class table__p_o_s_t(DefaultTable.DefaultTable): if glyphName in allNames: # make up a new glyphName that's unique n = allNames[glyphName] + while allNames.has_key(glyphName + "#" + str(n)): + n += 1 allNames[glyphName] = n + 1 - glyphName = glyphName + "#" + repr(n) + glyphName = glyphName + "#" + str(n) self.glyphOrder[i] = glyphName mapping[glyphName] = psName - else: - allNames[glyphName] = 1 + allNames[glyphName] = 1 self.mapping = mapping def decode_format_3_0(self, data, ttFont):