When compiling cmap format 6, fill in missing codes

They should just map to glyph 0.

Fixes https://github.com/behdad/fonttools/issues/42
This commit is contained in:
Behdad Esfahbod 2013-11-26 15:49:36 -05:00
parent 8c35239853
commit 13a08d0c3a

View File

@ -868,11 +868,9 @@ class cmap_format_6(CmapSubtable):
cmap = self.cmap
codes = cmap.keys()
if codes: # yes, there are empty cmap tables.
codes.sort()
lenCodes = len(codes)
assert codes == range(codes[0], codes[0] + lenCodes)
codes = range(codes[0], codes[-1] + 1)
firstCode = codes[0]
valueList = map(operator.getitem, [cmap]*lenCodes, codes)
valueList = [cmap.get(code, ".notdef") for code in codes]
valueList = map(ttFont.getGlyphID, valueList)
glyphIndexArray = array.array("H", valueList)
if sys.byteorder <> "big":