File: fontloop.py

package info (click to toggle)
fonts-junicode 2.211%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,448 kB
  • sloc: python: 304; sh: 236; xml: 18; makefile: 16
file content (29 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fontTools import ttLib
from fontTools.ttLib import ttFont, tables
import argparse

# A very simple program for looping through a font. This looks for
# big glyph programs, but it could be adapted to do any number of
# minor chores.

argparser = argparse.ArgumentParser(prog='xgridfit',
                                    description='Loop through a font.')
argparser.add_argument("inputfile", help='Font to process.')
argparser.add_argument("outputfile", nargs="?", help="Font to output.")
args = argparser.parse_args()
inputfile    = args.inputfile
outputfile   = args.outputfile
if not outputfile:
    outputfile = inputfile

thisFont = ttLib.TTFont(inputfile)
gn = thisFont.getGlyphNames()
for n in gn:
    glyph = thisFont['glyf'][n]
    try:
        proglen = len(glyph.program.getBytecode())
        if proglen > 400:
            print(str(proglen) + " " + n)
    except Exception:
        pass
# thisFont.save(outputfile, 1)