Use tableDict for DeltaValue lookbacks

Was abusing the set/getCount machinery before.
This commit is contained in:
Behdad Esfahbod 2013-11-24 17:10:55 -05:00
parent 078b36325d
commit 2edc2da303
2 changed files with 7 additions and 10 deletions

View File

@ -574,7 +574,7 @@ class BaseTable(object):
else: else:
table[conv.name] = conv.read(reader, font, table) table[conv.name] = conv.read(reader, font, table)
if conv.isCount or conv.isSize: if conv.isCount:
reader.setCount(conv.name, table[conv.name]) reader.setCount(conv.name, table[conv.name])
self.postRead(table, font) self.postRead(table, font)
@ -617,8 +617,6 @@ class BaseTable(object):
writer.writeCountReference(table, conv.name) writer.writeCountReference(table, conv.name)
else: else:
conv.write(writer, font, table, value) conv.write(writer, font, table, value)
if conv.isSize:
writer.setCount(conv.name, value)
def readFormat(self, reader): def readFormat(self, reader):
pass pass

View File

@ -46,7 +46,6 @@ class BaseConverter:
self.repeatOffset = repeatOffset self.repeatOffset = repeatOffset
self.tableClass = tableClass self.tableClass = tableClass
self.isCount = name.endswith("Count") self.isCount = name.endswith("Count")
self.isSize = name.endswith("Size") or name=="DeltaFormat"
def read(self, reader, font, tableDict): def read(self, reader, font, tableDict):
"""Read a value from the reader.""" """Read a value from the reader."""
@ -283,9 +282,9 @@ class ValueRecord(ValueFormat):
class DeltaValue(BaseConverter): class DeltaValue(BaseConverter):
def read(self, reader, font, tableDict): def read(self, reader, font, tableDict):
StartSize = reader.getCount("StartSize") StartSize = tableDict["StartSize"]
EndSize = reader.getCount("EndSize") EndSize = tableDict["EndSize"]
DeltaFormat = reader.getCount("DeltaFormat") DeltaFormat = tableDict["DeltaFormat"]
assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat" assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat"
nItems = EndSize - StartSize + 1 nItems = EndSize - StartSize + 1
nBits = 1 << DeltaFormat nBits = 1 << DeltaFormat
@ -306,9 +305,9 @@ class DeltaValue(BaseConverter):
return DeltaValue return DeltaValue
def write(self, writer, font, tableDict, value, repeatIndex=None): def write(self, writer, font, tableDict, value, repeatIndex=None):
StartSize = writer.getCount("StartSize") StartSize = tableDict["StartSize"]
EndSize = writer.getCount("EndSize") EndSize = tableDict["EndSize"]
DeltaFormat = writer.getCount("DeltaFormat") DeltaFormat = tableDict["DeltaFormat"]
DeltaValue = value DeltaValue = value
assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat" assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat"
nItems = EndSize - StartSize + 1 nItems = EndSize - StartSize + 1