Fixup for previous commit to make tests happy

This commit is contained in:
Behdad Esfahbod 2018-02-18 15:37:07 -08:00
parent fde3cf6560
commit e5f9674da6

View File

@ -386,7 +386,7 @@ def merge(self, m, tables):
# Build a unicode mapping, then decide which format is needed to store it. # Build a unicode mapping, then decide which format is needed to store it.
cmap = {} cmap = {}
fontIndexForGlyph = {} 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: for table,fontIdx in cmapTables:
# handle duplicates # handle duplicates
for uni,gid in table.cmap.items(): for uni,gid in table.cmap.items():
@ -398,12 +398,14 @@ def merge(self, m, tables):
# Char previously mapped to oldgid, now to gid. # Char previously mapped to oldgid, now to gid.
# Record, to fix up in GSUB 'locl' later. # Record, to fix up in GSUB 'locl' later.
if m.duplicateGlyphsPerFont[fontIdx].get(oldgid) is None: if m.duplicateGlyphsPerFont[fontIdx].get(oldgid) is None:
oldFontIdx = fontIndexForGlyph[oldgid] if glyphSets is not None:
for idx in (fontIdx, oldFontIdx): oldFontIdx = fontIndexForGlyph[oldgid]
if glyphSets[idx] is None: for idx in (fontIdx, oldFontIdx):
glyphSets[idx] = m.fonts[idx].getGlyphSet() if glyphSets[idx] is None:
if not _glyphsAreSame(glyphSets[oldFontIdx], glyphSets[fontIdx], oldgid, gid): glyphSets[idx] = m.fonts[idx].getGlyphSet()
m.duplicateGlyphsPerFont[fontIdx][oldgid] = gid if _glyphsAreSame(glyphSets[oldFontIdx], glyphSets[fontIdx], oldgid, gid):
continue
m.duplicateGlyphsPerFont[fontIdx][oldgid] = gid
elif m.duplicateGlyphsPerFont[fontIdx][oldgid] != gid: elif m.duplicateGlyphsPerFont[fontIdx][oldgid] != gid:
# Char previously mapped to oldgid but oldgid is already remapped to a different # Char previously mapped to oldgid but oldgid is already remapped to a different
# gid, because of another Unicode character. # gid, because of another Unicode character.