blob: 5b6c247a829c2d97e99938f0ef704a0e214a0400 [file] [log] [blame]
Just6cc58871999-12-16 22:04:30 +00001#! /usr/bin/env python
2
3"""\
4usage: %s [-h] [-v] [-t <table>] TrueType-file [XML-output-file]
5 -t <table> specify a table to dump. Multiple -t options
6 are allowed. When no -t option is specified, all tables
7 will be dumped
8 -v verbose: messages will be written to stdout about what is being done
9 -h help: print this message
10"""
11
12import sys, os, getopt
13from fontTools import ttLib
14
15options, args = getopt.getopt(sys.argv[1:], "hvt:")
16
17verbose = 0
18tables = []
19for option, value in options:
20 if option == "-t":
21 if len(value) > 4:
22 print "illegal table tag: " + value
23 sys.exit(2)
24 # normalize tag
25 value = value + (4 - len(value)) * " "
26 tables.append(value)
27 elif option == "-v":
28 verbose = 1
29 elif option == "-h":
30 print __doc__ % sys.argv[0]
31 sys.exit(0)
32
33
34if len(args) == 1:
35 ttpath = args[0]
36 name, ext = os.path.splitext(ttpath)
37 xmlpath = name + '.xml'
38elif len(args) == 2:
39 ttpath, xmlpath = args
40else:
41 print __doc__ % sys.argv[0]
42 sys.exit(2)
43
44tt = ttLib.TTFont(ttpath, verbose=verbose)
45tt.saveXML(xmlpath, tables=tables)