Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | """\ |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 4 | usage: %s [-h] [-v] [-i TrueType-input-file] XML-file [TrueType-output-file] |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 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 |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 7 | -b Don't recalc glyph boundig boxes: use the values in the XML file as-is. |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 8 | -h help: print this message |
| 9 | """ |
| 10 | import sys, os, getopt |
| 11 | from fontTools import ttLib |
| 12 | |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 13 | options, args = getopt.getopt(sys.argv[1:], "hvi:b") |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 14 | |
| 15 | verbose = 0 |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 16 | ttInFile = None |
| 17 | recalcBBoxes = 1 |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 18 | for option, value in options: |
| 19 | if option == "-i": |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 20 | ttInFile = value |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 21 | elif option == "-v": |
| 22 | verbose = 1 |
| 23 | elif option == "-h": |
| 24 | print __doc__ % sys.argv[0] |
| 25 | sys.exit(0) |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 26 | elif option == "-b": |
| 27 | recalcBBoxes = 0 |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 28 | |
| 29 | if len(args) == 1: |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 30 | xmlPath = args[0] |
| 31 | name, ext = os.path.splitext(xmlPath) |
| 32 | ttPath = name + '.ttf' |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 33 | elif len(args) == 2: |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 34 | xmlPath, ttPath = args |
Just | 6cc5887 | 1999-12-16 22:04:30 +0000 | [diff] [blame] | 35 | else: |
| 36 | print __doc__ % sys.argv[0] |
| 37 | sys.exit(2) |
| 38 | |
Just | ac7c6fa | 1999-12-18 18:12:15 +0000 | [diff] [blame^] | 39 | tt = ttLib.TTFont(ttInFile, verbose=verbose) |
| 40 | tt.importXML(xmlPath) |
| 41 | tt.save(ttPath, recalcBBoxes=recalcBBoxes) |