mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-11-18 16:03:23 +01:00
0cd0896629
Just realised theere is shrinkFont and allCharacters. Is it even worth it to recompile for every new character?
29 lines
927 B
Python
29 lines
927 B
Python
#!/usr/bin/python2
|
|
|
|
|
|
# By StackOverflow user SadaleNet:
|
|
# https://stackoverflow.com/questions/14557944/downsizing-an-otf-font-by-removing-glyphs/34132900#34132900
|
|
|
|
|
|
import sys
|
|
import fontforge
|
|
|
|
if len(sys.argv) == 4:
|
|
font = fontforge.open(sys.argv[1])
|
|
|
|
f = open(sys.argv[2], "r")
|
|
|
|
for i in f.read().decode("UTF-8"):
|
|
font.selection[ord(i)] = True
|
|
f.close()
|
|
|
|
font.selection.invert()
|
|
|
|
for i in font.selection.byGlyphs:
|
|
font.removeGlyph(i)
|
|
|
|
font.generate(sys.argv[3])
|
|
else:
|
|
print "WARNING: Check the license of the source font\nbefore distributing the output font generated by this script.\nI'm not responsible for any legal issue caused by\ninappropriate use of this script!\n"
|
|
print "Usage: {} [source font] [file with glyphs NOT to be removed] [output]".format(sys.argv[0])
|
|
print "Example: {} /path/to/ukai.ttc chineseTranslation.txt ukaiStripped.ttf".format(sys.argv[0])
|