blob: eac82a483e6b47069230b9fba2040561fe0a057e [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:
Justa7b9f291999-12-18 18:11:44 +000035 ttPath = args[0]
36 name, ext = os.path.splitext(ttPath)
37 xmlPath = name + '.xml'
Just6cc58871999-12-16 22:04:30 +000038elif len(args) == 2:
Justa7b9f291999-12-18 18:11:44 +000039 ttPath, xmlPath = args
Just6cc58871999-12-16 22:04:30 +000040else:
41 print __doc__ % sys.argv[0]
42 sys.exit(2)
43
Justa7b9f291999-12-18 18:11:44 +000044tt = ttLib.TTFont(ttPath, verbose=verbose)
45tt.saveXML(xmlPath, tables=tables)