[otConverters] Implement writeArray for GlyphID
This commit is contained in:
parent
bd648ea14d
commit
0b20c196d4
@ -338,6 +338,14 @@ class GlyphID(SimpleValue):
|
|||||||
return l
|
return l
|
||||||
def read(self, reader, font, tableDict):
|
def read(self, reader, font, tableDict):
|
||||||
return font.getGlyphName(reader.readValue(self.typecode, self.staticSize))
|
return font.getGlyphName(reader.readValue(self.typecode, self.staticSize))
|
||||||
|
def writeArray(self, writer, font, tableDict, values):
|
||||||
|
glyphMap = font.getReverseGlyphMap()
|
||||||
|
try:
|
||||||
|
values = [glyphMap[glyphname] for glyphname in values]
|
||||||
|
except KeyError:
|
||||||
|
# Slower, but will not throw a KeyError on an out-of-range glyph name.
|
||||||
|
values = [font.getGlyphID(glyphname) for glyphname in values]
|
||||||
|
writer.writeArray(self.typecode, values)
|
||||||
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
||||||
writer.writeValue(self.typecode, font.getGlyphID(value))
|
writer.writeValue(self.typecode, font.getGlyphID(value))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user