Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame^] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | """\ |
| 4 | usage: %s [-h] [-v] [-i TrueType-input-file] XML-file [TrueType-file] |
| 5 | -i TrueType-input-file: specify a TT file to be merged with the XML file |
| 6 | -v verbose: messages will be written to stdout about what is being done |
| 7 | -h help: print this message |
| 8 | """ |
| 9 | import sys, os, getopt |
| 10 | from fontTools import ttLib |
| 11 | |
| 12 | options, args = getopt.getopt(sys.argv[1:], "hvi:") |
| 13 | |
| 14 | verbose = 0 |
| 15 | tt_infile = None |
| 16 | for option, value in options: |
| 17 | if option == "-i": |
| 18 | tt_infile = value |
| 19 | elif option == "-v": |
| 20 | verbose = 1 |
| 21 | elif option == "-h": |
| 22 | print __doc__ % sys.argv[0] |
| 23 | sys.exit(0) |
| 24 | |
| 25 | |
| 26 | if len(args) == 1: |
| 27 | xmlpath = args[0] |
| 28 | name, ext = os.path.splitext(xmlpath) |
| 29 | ttpath = name + '.ttf' |
| 30 | elif len(args) == 2: |
| 31 | xmlpath, ttpath = args |
| 32 | else: |
| 33 | print __doc__ % sys.argv[0] |
| 34 | sys.exit(2) |
| 35 | |
| 36 | tt = ttLib.TTFont(tt_infile, verbose=verbose) |
| 37 | tt.importXML(xmlpath) |
| 38 | tt.save(ttpath) |