blob: a1dce2a2b2f482d5e793ddb180e25caed5f5901c [file] [log] [blame]
Just6cc58871999-12-16 22:04:30 +00001#! /usr/bin/env python
2
3"""\
Justac7c6fa1999-12-18 18:12:15 +00004usage: %s [-h] [-v] [-i TrueType-input-file] XML-file [TrueType-output-file]
Just6cc58871999-12-16 22:04:30 +00005 -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
Justac7c6fa1999-12-18 18:12:15 +00007 -b Don't recalc glyph boundig boxes: use the values in the XML file as-is.
Just6cc58871999-12-16 22:04:30 +00008 -h help: print this message
9"""
10import sys, os, getopt
11from fontTools import ttLib
12
Justac7c6fa1999-12-18 18:12:15 +000013options, args = getopt.getopt(sys.argv[1:], "hvi:b")
Just6cc58871999-12-16 22:04:30 +000014
15verbose = 0
Justac7c6fa1999-12-18 18:12:15 +000016ttInFile = None
17recalcBBoxes = 1
Just6cc58871999-12-16 22:04:30 +000018for option, value in options:
19 if option == "-i":
Justac7c6fa1999-12-18 18:12:15 +000020 ttInFile = value
Just6cc58871999-12-16 22:04:30 +000021 elif option == "-v":
22 verbose = 1
23 elif option == "-h":
24 print __doc__ % sys.argv[0]
25 sys.exit(0)
Justac7c6fa1999-12-18 18:12:15 +000026 elif option == "-b":
27 recalcBBoxes = 0
Just6cc58871999-12-16 22:04:30 +000028
29if len(args) == 1:
Justac7c6fa1999-12-18 18:12:15 +000030 xmlPath = args[0]
31 name, ext = os.path.splitext(xmlPath)
32 ttPath = name + '.ttf'
Just6cc58871999-12-16 22:04:30 +000033elif len(args) == 2:
Justac7c6fa1999-12-18 18:12:15 +000034 xmlPath, ttPath = args
Just6cc58871999-12-16 22:04:30 +000035else:
36 print __doc__ % sys.argv[0]
37 sys.exit(2)
38
Justac7c6fa1999-12-18 18:12:15 +000039tt = ttLib.TTFont(ttInFile, verbose=verbose)
40tt.importXML(xmlPath)
41tt.save(ttPath, recalcBBoxes=recalcBBoxes)