Skip to content

Instantly share code, notes, and snippets.

@graphicore
Created February 20, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicore/7618637aefbc474f6d69a294dab86616 to your computer and use it in GitHub Desktop.
Save graphicore/7618637aefbc474f6d69a294dab86616 to your computer and use it in GitHub Desktop.
Used to plot memory usage with `mprof` (python memory-profiler)
#!/usr/bin/env python
from fontTools.ttLib import TTFont
# using sleep to
from time import sleep
import sys
if __name__ == '__main__':
fonts = [font for font in sys.argv if font.endswith('tf')]
ttfonts = []
for font in fonts:
print(font)
ttfont = TTFont(font)
ttfonts.append(ttfont)
sleep(1)
sleep(1)
# Decompile all tables
for ttfont in ttfonts:
print(ttfonts)
for key in ttfont.keys():
try:
ttfont[key]
except:
print('fail: ', key)
pass
sleep(1)
# Will we see this with mprof? Spoiler: No.
while ttfonts:
ttfont = ttfonts.pop()
print('del', ttfont)
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment