From ee27b73d7c3fddd251ab7bc9e2b311b106c5b095 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 17 Mar 2022 12:54:22 +0000 Subject: [PATCH] BaseTTXConverter: add ensureDecompiled method to unlazify a whole tree of otTables, recursively --- Lib/fontTools/ttLib/tables/otBase.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index a3f5ac8ea..c9c1d138d 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -108,6 +108,9 @@ class BaseTTXConverter(DefaultTable): self.table.fromXML(name, attrs, content, font) self.table.populateDefaults() + def ensureDecompiled(self): + self.table.ensureDecompiled(recurse=True) + # https://github.com/fonttools/fonttools/pull/2285#issuecomment-834652928 assert len(struct.pack('i', 0)) == 4 @@ -596,13 +599,16 @@ class BaseTable(object): raise AttributeError(attr) - def ensureDecompiled(self): + def ensureDecompiled(self, recurse=False): reader = self.__dict__.get("reader") if reader: del self.reader font = self.font del self.font self.decompile(reader, font) + if recurse: + for subtable in self.iterSubTables(): + subtable.ensureDecompiled(recurse) @classmethod def getRecordSize(cls, reader):