Merge pull request #2626 from googlefonts/table_sharing

Enable sharing across subtables of extension for harfbuzz packing.
This commit is contained in:
Cosimo Lupo 2022-06-09 11:02:29 +01:00 committed by GitHub
commit a367e8acf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -380,7 +380,7 @@ class OTTableWriter(object):
return NotImplemented return NotImplemented
return self.offsetSize == other.offsetSize and self.items == other.items return self.offsetSize == other.offsetSize and self.items == other.items
def _doneWriting(self, internedTables): def _doneWriting(self, internedTables, shareExtension=False):
# Convert CountData references to data string items # Convert CountData references to data string items
# collapse duplicate table references to a unique entry # collapse duplicate table references to a unique entry
# "tables" are OTTableWriter objects. # "tables" are OTTableWriter objects.
@ -396,7 +396,7 @@ class OTTableWriter(object):
# See: https://github.com/fonttools/fonttools/issues/518 # See: https://github.com/fonttools/fonttools/issues/518
dontShare = hasattr(self, 'DontShare') dontShare = hasattr(self, 'DontShare')
if isExtension: if isExtension and not shareExtension:
internedTables = {} internedTables = {}
items = self.items items = self.items
@ -405,7 +405,7 @@ class OTTableWriter(object):
if hasattr(item, "getCountData"): if hasattr(item, "getCountData"):
items[i] = item.getCountData() items[i] = item.getCountData()
elif hasattr(item, "getData"): elif hasattr(item, "getData"):
item._doneWriting(internedTables) item._doneWriting(internedTables, shareExtension=shareExtension)
# At this point, all subwriters are hashable based on their items. # At this point, all subwriters are hashable based on their items.
# (See hash and comparison magic methods above.) So the ``setdefault`` # (See hash and comparison magic methods above.) So the ``setdefault``
# call here will return the first writer object we've seen with # call here will return the first writer object we've seen with
@ -533,7 +533,7 @@ class OTTableWriter(object):
https://github.com/harfbuzz/uharfbuzz/blob/main/src/uharfbuzz/_harfbuzz.pyx#L1149 https://github.com/harfbuzz/uharfbuzz/blob/main/src/uharfbuzz/_harfbuzz.pyx#L1149
""" """
internedTables = {} internedTables = {}
self._doneWriting(internedTables) self._doneWriting(internedTables, shareExtension=True)
tables = [] tables = []
obj_list = [] obj_list = []
done = {} done = {}