Created
March 13, 2023 07:28
-
-
Save simoncozens/eb1a1ef3e913bf45ddade6a173bf0f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fontTools.ttLib import TTFont | |
from fontTools.ttLib.tables.otBase import OTTableWriter | |
import sys | |
from fontTools.feaLib.lookupDebugInfo import LOOKUP_DEBUG_INFO_KEY | |
font = TTFont(sys.argv[1]) | |
def locate(table, ix): | |
if "Debg" not in font: | |
return str(ix) | |
debg = font["Debg"].data[LOOKUP_DEBUG_INFO_KEY][table].get(str(ix)) | |
if debg: | |
return f"{ix} = {debg[0]} ({debg[1]})" | |
return str(ix) | |
for table in ["GSUB", "GPOS"]: | |
print(f"{table} table") | |
print("==========\n") | |
lookups = font.get(table).table.LookupList.Lookup | |
sizes = [] | |
for ix, lookup in enumerate(lookups): | |
writer = OTTableWriter() | |
lookup.compile(writer, font) | |
sizes.append((locate(table, ix), len(writer.getAllData()))) | |
for location, size in (list(sorted(sizes, key=lambda a:-a[1])))[0:10]: | |
print(location, "\t", size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment