fonttools/tt2xml.py
Just a7b9f2919e changed some variable names.
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@12 4cde692c-a291-49d1-8350-778aa11640f8
1999-12-18 18:11:44 +00:00

46 lines
1.0 KiB
Python

#! /usr/bin/env python
"""\
usage: %s [-h] [-v] [-t <table>] TrueType-file [XML-output-file]
-t <table> specify a table to dump. Multiple -t options
are allowed. When no -t option is specified, all tables
will be dumped
-v verbose: messages will be written to stdout about what is being done
-h help: print this message
"""
import sys, os, getopt
from fontTools import ttLib
options, args = getopt.getopt(sys.argv[1:], "hvt:")
verbose = 0
tables = []
for option, value in options:
if option == "-t":
if len(value) > 4:
print "illegal table tag: " + value
sys.exit(2)
# normalize tag
value = value + (4 - len(value)) * " "
tables.append(value)
elif option == "-v":
verbose = 1
elif option == "-h":
print __doc__ % sys.argv[0]
sys.exit(0)
if len(args) == 1:
ttPath = args[0]
name, ext = os.path.splitext(ttPath)
xmlPath = name + '.xml'
elif len(args) == 2:
ttPath, xmlPath = args
else:
print __doc__ % sys.argv[0]
sys.exit(2)
tt = ttLib.TTFont(ttPath, verbose=verbose)
tt.saveXML(xmlPath, tables=tables)