Ignore class=0 when reading & writing ClassDef objects
class=0 items might be added as an optimization. They have no semantic value. Ignore them. Fixes the last of mtiLib tests.
This commit is contained in:
parent
101303ab50
commit
2d3610bb6b
@ -54,8 +54,6 @@
|
|||||||
<ClassDef glyph="Ocircumflex" class="2"/>
|
<ClassDef glyph="Ocircumflex" class="2"/>
|
||||||
<ClassDef glyph="Ograve" class="2"/>
|
<ClassDef glyph="Ograve" class="2"/>
|
||||||
<ClassDef glyph="T" class="3"/>
|
<ClassDef glyph="T" class="3"/>
|
||||||
<ClassDef glyph="V" class="0"/>
|
|
||||||
<ClassDef glyph="acircumflex" class="0"/>
|
|
||||||
</ClassDef1>
|
</ClassDef1>
|
||||||
<ClassDef2 Format="2">
|
<ClassDef2 Format="2">
|
||||||
<ClassDef glyph="V" class="1"/>
|
<ClassDef glyph="V" class="1"/>
|
||||||
|
@ -389,7 +389,8 @@ class ClassDef(FormatSwitchingBaseTable):
|
|||||||
endID = len(glyphOrder)
|
endID = len(glyphOrder)
|
||||||
|
|
||||||
for glyphID, cls in zip(range(startID, endID), classList):
|
for glyphID, cls in zip(range(startID, endID), classList):
|
||||||
classDefs[glyphOrder[glyphID]] = cls
|
if cls:
|
||||||
|
classDefs[glyphOrder[glyphID]] = cls
|
||||||
|
|
||||||
elif self.Format == 2:
|
elif self.Format == 2:
|
||||||
records = rawTable["ClassRangeRecord"]
|
records = rawTable["ClassRangeRecord"]
|
||||||
@ -412,7 +413,8 @@ class ClassDef(FormatSwitchingBaseTable):
|
|||||||
# but none that we have seen in the wild.
|
# but none that we have seen in the wild.
|
||||||
endID = len(glyphOrder)
|
endID = len(glyphOrder)
|
||||||
for glyphID in range(startID, endID):
|
for glyphID in range(startID, endID):
|
||||||
classDefs[glyphOrder[glyphID]] = cls
|
if cls:
|
||||||
|
classDefs[glyphOrder[glyphID]] = cls
|
||||||
else:
|
else:
|
||||||
assert 0, "unknown format: %s" % self.Format
|
assert 0, "unknown format: %s" % self.Format
|
||||||
self.classDefs = classDefs
|
self.classDefs = classDefs
|
||||||
@ -421,13 +423,13 @@ class ClassDef(FormatSwitchingBaseTable):
|
|||||||
classDefs = getattr(self, "classDefs", None)
|
classDefs = getattr(self, "classDefs", None)
|
||||||
if classDefs is None:
|
if classDefs is None:
|
||||||
classDefs = self.classDefs = {}
|
classDefs = self.classDefs = {}
|
||||||
items = list(classDefs.items())
|
|
||||||
format = 2
|
format = 2
|
||||||
rawTable = {"ClassRangeRecord": []}
|
rawTable = {"ClassRangeRecord": []}
|
||||||
getGlyphID = font.getGlyphID
|
getGlyphID = font.getGlyphID
|
||||||
for i in range(len(items)):
|
items = []
|
||||||
glyphName, cls = items[i]
|
for glyphName, cls in classDefs.items():
|
||||||
items[i] = getGlyphID(glyphName), glyphName, cls
|
if not cls: continue
|
||||||
|
items.append((getGlyphID(glyphName), glyphName, cls))
|
||||||
items.sort()
|
items.sort()
|
||||||
if items:
|
if items:
|
||||||
last, lastName, lastCls = items[0]
|
last, lastName, lastCls = items[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user