From e5f9674da614fb600001f44c9c2a0cd8387095af Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 18 Feb 2018 15:37:07 -0800 Subject: [PATCH] Fixup for previous commit to make tests happy --- Lib/fontTools/merge.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Lib/fontTools/merge.py b/Lib/fontTools/merge.py index a5426b82b..8c0be2c1d 100644 --- a/Lib/fontTools/merge.py +++ b/Lib/fontTools/merge.py @@ -386,7 +386,7 @@ def merge(self, m, tables): # Build a unicode mapping, then decide which format is needed to store it. cmap = {} fontIndexForGlyph = {} - glyphSets = [None for f in m.fonts] + glyphSets = [None for f in m.fonts] if hasattr(m, 'fonts') else None for table,fontIdx in cmapTables: # handle duplicates for uni,gid in table.cmap.items(): @@ -398,12 +398,14 @@ def merge(self, m, tables): # Char previously mapped to oldgid, now to gid. # Record, to fix up in GSUB 'locl' later. if m.duplicateGlyphsPerFont[fontIdx].get(oldgid) is None: - oldFontIdx = fontIndexForGlyph[oldgid] - for idx in (fontIdx, oldFontIdx): - if glyphSets[idx] is None: - glyphSets[idx] = m.fonts[idx].getGlyphSet() - if not _glyphsAreSame(glyphSets[oldFontIdx], glyphSets[fontIdx], oldgid, gid): - m.duplicateGlyphsPerFont[fontIdx][oldgid] = gid + if glyphSets is not None: + oldFontIdx = fontIndexForGlyph[oldgid] + for idx in (fontIdx, oldFontIdx): + if glyphSets[idx] is None: + glyphSets[idx] = m.fonts[idx].getGlyphSet() + if _glyphsAreSame(glyphSets[oldFontIdx], glyphSets[fontIdx], oldgid, gid): + continue + m.duplicateGlyphsPerFont[fontIdx][oldgid] = gid elif m.duplicateGlyphsPerFont[fontIdx][oldgid] != gid: # Char previously mapped to oldgid but oldgid is already remapped to a different # gid, because of another Unicode character.