Use tableDict for DeltaValue lookbacks
Was abusing the set/getCount machinery before.
This commit is contained in:
parent
078b36325d
commit
2edc2da303
@ -574,7 +574,7 @@ class BaseTable(object):
|
||||
|
||||
else:
|
||||
table[conv.name] = conv.read(reader, font, table)
|
||||
if conv.isCount or conv.isSize:
|
||||
if conv.isCount:
|
||||
reader.setCount(conv.name, table[conv.name])
|
||||
|
||||
self.postRead(table, font)
|
||||
@ -617,8 +617,6 @@ class BaseTable(object):
|
||||
writer.writeCountReference(table, conv.name)
|
||||
else:
|
||||
conv.write(writer, font, table, value)
|
||||
if conv.isSize:
|
||||
writer.setCount(conv.name, value)
|
||||
|
||||
def readFormat(self, reader):
|
||||
pass
|
||||
|
@ -46,7 +46,6 @@ class BaseConverter:
|
||||
self.repeatOffset = repeatOffset
|
||||
self.tableClass = tableClass
|
||||
self.isCount = name.endswith("Count")
|
||||
self.isSize = name.endswith("Size") or name=="DeltaFormat"
|
||||
|
||||
def read(self, reader, font, tableDict):
|
||||
"""Read a value from the reader."""
|
||||
@ -283,9 +282,9 @@ class ValueRecord(ValueFormat):
|
||||
class DeltaValue(BaseConverter):
|
||||
|
||||
def read(self, reader, font, tableDict):
|
||||
StartSize = reader.getCount("StartSize")
|
||||
EndSize = reader.getCount("EndSize")
|
||||
DeltaFormat = reader.getCount("DeltaFormat")
|
||||
StartSize = tableDict["StartSize"]
|
||||
EndSize = tableDict["EndSize"]
|
||||
DeltaFormat = tableDict["DeltaFormat"]
|
||||
assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat"
|
||||
nItems = EndSize - StartSize + 1
|
||||
nBits = 1 << DeltaFormat
|
||||
@ -306,9 +305,9 @@ class DeltaValue(BaseConverter):
|
||||
return DeltaValue
|
||||
|
||||
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
||||
StartSize = writer.getCount("StartSize")
|
||||
EndSize = writer.getCount("EndSize")
|
||||
DeltaFormat = writer.getCount("DeltaFormat")
|
||||
StartSize = tableDict["StartSize"]
|
||||
EndSize = tableDict["EndSize"]
|
||||
DeltaFormat = tableDict["DeltaFormat"]
|
||||
DeltaValue = value
|
||||
assert DeltaFormat in (1, 2, 3), "illegal DeltaFormat"
|
||||
nItems = EndSize - StartSize + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user