When lazy-loading tables, copy ValueFormat
Otherwise it may be overwritten before we use it.
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index f752845..0e1e1f7 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -98,16 +98,19 @@
self.valueFormat = valueFormat
self.cachingStats = cachingStats
- def getSubReader(self, offset):
+ def getSubReader(self, offset, persistent=False):
offset = self.offset + offset
if self.cachingStats is not None:
try:
self.cachingStats[offset] = self.cachingStats[offset] + 1
except KeyError:
self.cachingStats[offset] = 1
-
+ valueFormat = self.valueFormat
+ if persistent:
+ valueFormat = tuple(ValueRecordFactory(v) for v in valueFormat)
+
subReader = self.__class__(self.data, self.tableType, offset,
- self.valueFormat, self.cachingStats)
+ valueFormat, self.cachingStats)
return subReader
def readUShort(self):
@@ -743,6 +746,9 @@
class ValueRecordFactory:
"""Given a format code, this object convert ValueRecords."""
+
+ def __init__(self, other=None):
+ self.format = other.format if other else None
def setFormat(self, valueFormat):
format = []