return self so one can do font=TTFont(file).ensureDecompiled()
This commit is contained in:
parent
46f33357cb
commit
61e7b29448
@ -162,6 +162,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable):
|
|||||||
def ensureDecompiled(self):
|
def ensureDecompiled(self):
|
||||||
for st in self.tables:
|
for st in self.tables:
|
||||||
st.ensureDecompiled()
|
st.ensureDecompiled()
|
||||||
|
return self
|
||||||
|
|
||||||
def compile(self, ttFont):
|
def compile(self, ttFont):
|
||||||
self.tables.sort() # sort according to the spec; see CmapSubtable.__lt__()
|
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
|
self.data = None # Once this table has been decompiled, make sure we don't
|
||||||
# just return the original data. Also avoids recursion when
|
# just return the original data. Also avoids recursion when
|
||||||
# called with an attribute that the cmap subtable doesn't have.
|
# called with an attribute that the cmap subtable doesn't have.
|
||||||
|
return self
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
# allow lazy decompilation of subtables.
|
# allow lazy decompilation of subtables.
|
||||||
|
@ -115,6 +115,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
|||||||
def ensureDecompiled(self):
|
def ensureDecompiled(self):
|
||||||
for glyph in self.glyphs.values():
|
for glyph in self.glyphs.values():
|
||||||
glyph.expand(self)
|
glyph.expand(self)
|
||||||
|
return self
|
||||||
|
|
||||||
def compile(self, ttFont):
|
def compile(self, ttFont):
|
||||||
if not hasattr(self, "glyphOrder"):
|
if not hasattr(self, "glyphOrder"):
|
||||||
|
@ -110,6 +110,7 @@ class BaseTTXConverter(DefaultTable):
|
|||||||
|
|
||||||
def ensureDecompiled(self):
|
def ensureDecompiled(self):
|
||||||
self.table.ensureDecompiled(recurse=True)
|
self.table.ensureDecompiled(recurse=True)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
# https://github.com/fonttools/fonttools/pull/2285#issuecomment-834652928
|
# https://github.com/fonttools/fonttools/pull/2285#issuecomment-834652928
|
||||||
@ -609,6 +610,7 @@ class BaseTable(object):
|
|||||||
if recurse:
|
if recurse:
|
||||||
for subtable in self.iterSubTables():
|
for subtable in self.iterSubTables():
|
||||||
subtable.ensureDecompiled(recurse)
|
subtable.ensureDecompiled(recurse)
|
||||||
|
return self
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getRecordSize(cls, reader):
|
def getRecordSize(cls, reader):
|
||||||
|
@ -379,12 +379,16 @@ class TTFont(object):
|
|||||||
return ["GlyphOrder"] + keys
|
return ["GlyphOrder"] + keys
|
||||||
|
|
||||||
def ensureDecompiled(self):
|
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():
|
for tag in self.keys():
|
||||||
table = self[tag]
|
table = self[tag]
|
||||||
if self.lazy is not False and hasattr(table, "ensureDecompiled"):
|
if self.lazy is not False and hasattr(table, "ensureDecompiled"):
|
||||||
table.ensureDecompiled()
|
table.ensureDecompiled()
|
||||||
self.lazy = False
|
self.lazy = False
|
||||||
|
return self
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(list(self.keys()))
|
return len(list(self.keys()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user