Created
February 20, 2019 17:41
-
-
Save graphicore/7618637aefbc474f6d69a294dab86616 to your computer and use it in GitHub Desktop.
Used to plot memory usage with `mprof` (python memory-profiler)
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
#!/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