diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2014-05-14 00:12:03 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2014-05-14 00:12:03 -0400 |
commit | 470d610eb2cba2629889b00575742921079bc1cb (patch) | |
tree | d071f60a53f910701612dceb5b3812716c8b91f5 | |
parent | 2db5eca0df1ff21f4c6bb5dee44512bf02e3f203 (diff) | |
download | fonttools-470d610eb2cba2629889b00575742921079bc1cb.tar.gz |
Further micro-optimize cmap subtable format 4 loading
-rw-r--r-- | Lib/fontTools/ttLib/tables/_c_m_a_p.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index 3954d5ce..cec66231 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -673,17 +673,17 @@ class cmap_format_4(CmapSubtable): rangeCharCodes = list(range(startCode[i], endCode[i] + 1)) charCodes.extend(rangeCharCodes) - for charCode in rangeCharCodes: - if rangeOffset == 0: - glyphID = charCode + delta - else: + if rangeOffset == 0: + gids.extend([(charCode + delta) & 0xFFFF for charCode in rangeCharCodes]) + else: + for charCode in rangeCharCodes: index = charCode + partial assert (index < lenGIArray), "In format 4 cmap, range (%d), the calculated index (%d) into the glyph index array is not less than the length of the array (%d) !" % (i, index, lenGIArray) if glyphIndexArray[index] != 0: # if not missing glyph glyphID = glyphIndexArray[index] + delta else: glyphID = 0 # missing glyph - gids.append(glyphID % 0x10000) + gids.append(glyphID & 0xFFFF) self.cmap = cmap = {} lenCmap = len(gids) |