diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index a31b5059c..92e1c17a0 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -162,6 +162,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable): def ensureDecompiled(self): for st in self.tables: st.ensureDecompiled() + return self def compile(self, ttFont): self.tables.sort() # sort according to the spec; see CmapSubtable.__lt__() @@ -245,6 +246,7 @@ class CmapSubtable(object): self.data = None # Once this table has been decompiled, make sure we don't # just return the original data. Also avoids recursion when # called with an attribute that the cmap subtable doesn't have. + return self def __getattr__(self, attr): # allow lazy decompilation of subtables. diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 14c4519db..3de9d28e3 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -115,6 +115,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable): def ensureDecompiled(self): for glyph in self.glyphs.values(): glyph.expand(self) + return self def compile(self, ttFont): if not hasattr(self, "glyphOrder"): diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index c9c1d138d..5bc4f0eed 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -110,6 +110,7 @@ class BaseTTXConverter(DefaultTable): def ensureDecompiled(self): self.table.ensureDecompiled(recurse=True) + return self # https://github.com/fonttools/fonttools/pull/2285#issuecomment-834652928 @@ -609,6 +610,7 @@ class BaseTable(object): if recurse: for subtable in self.iterSubTables(): subtable.ensureDecompiled(recurse) + return self @classmethod def getRecordSize(cls, reader): diff --git a/Lib/fontTools/ttLib/ttFont.py b/Lib/fontTools/ttLib/ttFont.py index 3929e2f3e..8bf6614cc 100644 --- a/Lib/fontTools/ttLib/ttFont.py +++ b/Lib/fontTools/ttLib/ttFont.py @@ -379,12 +379,16 @@ class TTFont(object): return ["GlyphOrder"] + keys def ensureDecompiled(self): - """Decompile all the tables, even if a TTFont was opened in 'lazy' mode.""" + """Decompile all the tables, even if a TTFont was opened in 'lazy' mode. + + Returns the same TTFont instance, fully decompiled. + """ for tag in self.keys(): table = self[tag] if self.lazy is not False and hasattr(table, "ensureDecompiled"): table.ensureDecompiled() self.lazy = False + return self def __len__(self): return len(list(self.keys()))