TTFont: don't load all tables upon opening even with lazy=False

one has to call TTFont.ensureDecompiled to load everything
This commit is contained in:
Cosimo Lupo 2022-03-17 13:47:25 +00:00
parent 795bccd966
commit 46f33357cb

View File

@ -129,7 +129,7 @@ class TTFont(object):
closeStream = False
file.seek(0)
if self.lazy is None:
if not self.lazy:
# read input file in memory and wrap a stream around it to allow overwriting
file.seek(0)
tmp = BytesIO(file.read())
@ -139,19 +139,12 @@ class TTFont(object):
if closeStream:
file.close()
file = tmp
self._tableCache = _tableCache
self.reader = SFNTReader(file, checkChecksums, fontNumber=fontNumber)
self.sfntVersion = self.reader.sfntVersion
self.flavor = self.reader.flavor
self.flavorData = self.reader.flavorData
if self.lazy is False:
# if lazy=False immediately load all the tables
self.ensureDecompiled()
if closeStream:
file.close()
def __enter__(self):
return self