remove some unused variables; test empty cmap for format 4
This commit is contained in:
parent
d4a2d935c4
commit
7c319abbec
@ -442,7 +442,6 @@ class cmap_format_2(CmapSubtable):
|
|||||||
charCodes = [item[0] for item in items]
|
charCodes = [item[0] for item in items]
|
||||||
names = [item[1] for item in items]
|
names = [item[1] for item in items]
|
||||||
nameMap = ttFont.getReverseGlyphMap()
|
nameMap = ttFont.getReverseGlyphMap()
|
||||||
lenCharCodes = len(charCodes)
|
|
||||||
try:
|
try:
|
||||||
gids = [nameMap[name] for name in names]
|
gids = [nameMap[name] for name in names]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -744,8 +743,7 @@ class cmap_format_4(CmapSubtable):
|
|||||||
return struct.pack(">HHH", self.format, self.length, self.language) + self.data
|
return struct.pack(">HHH", self.format, self.length, self.language) + self.data
|
||||||
|
|
||||||
charCodes = list(self.cmap.keys())
|
charCodes = list(self.cmap.keys())
|
||||||
lenCharCodes = len(charCodes)
|
if not charCodes:
|
||||||
if lenCharCodes == 0:
|
|
||||||
startCode = [0xffff]
|
startCode = [0xffff]
|
||||||
endCode = [0xffff]
|
endCode = [0xffff]
|
||||||
else:
|
else:
|
||||||
@ -956,7 +954,6 @@ class cmap_format_12_or_13(CmapSubtable):
|
|||||||
if self.data:
|
if self.data:
|
||||||
return struct.pack(">HHLLL", self.format, self.reserved, self.length, self.language, self.nGroups) + self.data
|
return struct.pack(">HHLLL", self.format, self.reserved, self.length, self.language, self.nGroups) + self.data
|
||||||
charCodes = list(self.cmap.keys())
|
charCodes = list(self.cmap.keys())
|
||||||
lenCharCodes = len(charCodes)
|
|
||||||
names = list(self.cmap.values())
|
names = list(self.cmap.values())
|
||||||
nameMap = ttFont.getReverseGlyphMap()
|
nameMap = ttFont.getReverseGlyphMap()
|
||||||
try:
|
try:
|
||||||
|
@ -82,6 +82,16 @@ class CmapSubtableTest(unittest.TestCase):
|
|||||||
font.setGlyphOrder([".notdef"])
|
font.setGlyphOrder([".notdef"])
|
||||||
data = subtable.compile(font)
|
data = subtable.compile(font)
|
||||||
|
|
||||||
|
def test_compile_decompile_4_empty(self):
|
||||||
|
subtable = self.makeSubtable(4, 3, 1, 0)
|
||||||
|
subtable.cmap = {}
|
||||||
|
font = ttLib.TTFont()
|
||||||
|
font.setGlyphOrder([])
|
||||||
|
data = subtable.compile(font)
|
||||||
|
subtable2 = CmapSubtable.newSubtable(4)
|
||||||
|
subtable2.decompile(data, font)
|
||||||
|
self.assertEqual(subtable2.cmap, {})
|
||||||
|
|
||||||
def test_decompile_4(self):
|
def test_decompile_4(self):
|
||||||
subtable = CmapSubtable.newSubtable(4)
|
subtable = CmapSubtable.newSubtable(4)
|
||||||
font = ttLib.TTFont()
|
font = ttLib.TTFont()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user