don't use __len__ for arbitrary length method
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@287 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 5a7734f..b26f531 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -142,16 +142,6 @@
else:
return cmp(id(self), id(other))
- def __len__(self):
- """Return the length of this table in bytes, without subtables."""
- l = 0
- for item in self.items:
- if hasattr(item, "getData") or hasattr(item, "getCountData"):
- l = l + 2 # sizeof(UShort)
- else:
- l = l + len(item)
- return l
-
def _doneWriting(self, internedTables=None):
if internedTables is None:
internedTables = {}
@@ -190,7 +180,7 @@
pos = 0
for table in tables:
table.pos = pos
- pos = pos + len(table)
+ pos = pos + table.getDataLength()
data = []
for table in tables:
@@ -199,6 +189,16 @@
return "".join(data)
+ def getDataLength(self):
+ """Return the length of this table in bytes, without subtables."""
+ l = 0
+ for item in self.items:
+ if hasattr(item, "getData") or hasattr(item, "getCountData"):
+ l = l + 2 # sizeof(UShort)
+ else:
+ l = l + len(item)
+ return l
+
def getData(self):
"""Return the data for this writer/table, without any subtables."""
items = list(self.items) # make a shallow copy