Skip to content

Instantly share code, notes, and snippets.

View graphicore's full-sized avatar
🎯
Focusing then blurring again …

Lasse Fister graphicore

🎯
Focusing then blurring again …
View GitHub Profile
@graphicore
graphicore / ttfont-decompile.py
Created February 20, 2019 17:41
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 = []
javascript:void((function%20()%7Bvar%20collected%20=%20new%20Map(),%20unique%20=%20new%20Map(),%20tags%20=%20Symbol('tags'),%20size%20=%20Symbol('size');for(elem%20of%20document.getElementsByTagName(%22*%22))%20%7Blet%20computed%20=%20window.getComputedStyle(elem,null);if%20(computed.display%20===%20'none')continue;if(elem.offsetParent%20===%20null%20&&%20computed.position%20!==%20'fixed')/*%20a%20parent%20node%20is%20hidden%20*/continue;if(!Array.from(elem.childNodes).some(node=%3E/*%20is%20a%20text%20Node%20*/node.nodeType%20===%20Node.TEXT_NODE%20&&/*%20only%20whitespace*/node.wholeText.trim()%20!==%20''))continue;let%20fontFamily%20=%20computed.getPropertyValue('font-family'),%20fontSize%20=%20computed.getPropertyValue('font-size'),%20fontWeight%20=%20computed.getPropertyValue('font-weight'),%20fontStyle%20=%20computed.getPropertyValue('font-style'),%20fontVariationSettings%20=%20computed.getPropertyValue('font-variation-settings'),%20key%20=%20%60$%7BfontFamily%7D%60,%20id%20=%20%5BfontSize,%20fontFamily