diff --git a/tt2xml.py b/tt2xml.py deleted file mode 100644 index 32ce4db71..000000000 --- a/tt2xml.py +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/env python - -"""\ -usage: %s [-hvs] [-t ] [-x
] TrueType-file [XML-output-file] - Dump a TrueType font as an XML file. If the XML-output-file argument - is omitted, the out put file name will be constructed from the input - file name, like so: *.ttf becomes *.xml. Either way, existing files - will be overwritten without warning! - - Options: - -t
specify a table to dump. Multiple -t options - are allowed. When no -t option is specified, all tables - will be dumped - -x
specify a table to exclude from the dump. Multiple - -x options are allowed. -t and -x are mutually exclusive. - -v verbose: messages will be written to stdout about what is - being done. - -s split tables: save the XML in a separate XML file per table. - The files will be saved in a directory. The name of this - directory will be constructed from the input filename (by - dropping the extension) or can be specified by the optional - XML-output-file argument. - -h help: print this message -""" - -import sys, os, getopt -from fontTools import ttLib - -options, args = getopt.getopt(sys.argv[1:], "shvt:x:") - -verbose = 0 -splitTables = 0 -tables = [] -skipTables = [] -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 == "-x": - if len(value) > 4: - print "illegal table tag: " + value - sys.exit(2) - # normalize tag - value = value + (4 - len(value)) * " " - skipTables.append(value) - elif option == "-v": - verbose = 1 - elif option == "-h": - print __doc__ % sys.argv[0] - sys.exit(0) - elif option == "-s": - splitTables = 1 - -if tables and skipTables: - print "-t and -x options are mutually exlusive" - sys.exit(2) - -if len(args) == 1: - ttPath = args[0] - path, ext = os.path.splitext(ttPath) - if splitTables: - xmlPath = path - else: - xmlPath = path + '.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, skipTables=skipTables, splitTables=splitTables) diff --git a/ttCompile.py b/ttCompile.py index 4ec866683..d2136db94 100644 --- a/ttCompile.py +++ b/ttCompile.py @@ -1,16 +1,16 @@ #! /usr/bin/env python """\ -usage: %s [-hvb] [-i TrueType-input-file] XML-file [TrueType-output-file] - Translate an XML file (as output by tt2xml.py) to a TrueType font file. - If the XML-file argument is a directory instead of a file, all files - ending in '.xml' will be merged into one TrueType file. This is mostly - useful in conjunction with the -s option of tt2xml.py. +usage: %s [-hvb] [-i TrueType-input-file] TTX-file [TrueType-output-file] + Translate an TTX file (as output by ttDump.py) to a TrueType font file. + If the TTX-file argument is a directory instead of a file, all files in + that directory ending in '.ttx' will be merged into one TrueType file. + This is mostly useful in conjunction with the -s option of ttDump.py. Options: - -i TrueType-input-file: specify a TT file to be merged with the XML file(s) + -i TrueType-input-file: specify a TT file to be merged with the TTX file(s) -v verbose: messages will be written to stdout about what is being done - -b Don't recalc glyph boundig boxes: use the values in the XML file as-is. + -b Don't recalc glyph boundig boxes: use the values in the TTX file as-is. -h help: print this message """ import sys, os, getopt @@ -48,7 +48,7 @@ if os.path.isdir(xmlPath): import glob oldDir = os.getcwd() os.chdir(xmlPath) - files = glob.glob("*.xml") + files = glob.glob("*.ttx") os.chdir(oldDir) for xmlFile in files: xmlFile = os.path.join(xmlPath, xmlFile) diff --git a/ttDump.py b/ttDump.py index 32ce4db71..9d0ea1bef 100644 --- a/ttDump.py +++ b/ttDump.py @@ -1,11 +1,11 @@ #! /usr/bin/env python """\ -usage: %s [-hvs] [-t
] [-x
] TrueType-file [XML-output-file] - Dump a TrueType font as an XML file. If the XML-output-file argument - is omitted, the out put file name will be constructed from the input - file name, like so: *.ttf becomes *.xml. Either way, existing files - will be overwritten without warning! +usage: %s [-hvs] [-t
] [-x
] TrueType-file [TTX-output-file] + Dump a TrueType font as a TTX file (an XML-based text format). If the + TTX-output-file argument is omitted, the out put file name will be + constructed from the input file name, like so: *.ttf becomes *.ttx. + Either way, existing files will be overwritten without warning! Options: -t
specify a table to dump. Multiple -t options @@ -15,11 +15,11 @@ usage: %s [-hvs] [-t
] [-x
] TrueType-file [XML-output-file] -x options are allowed. -t and -x are mutually exclusive. -v verbose: messages will be written to stdout about what is being done. - -s split tables: save the XML in a separate XML file per table. + -s split tables: save the TTX data into separate TTX files per table. The files will be saved in a directory. The name of this directory will be constructed from the input filename (by dropping the extension) or can be specified by the optional - XML-output-file argument. + TTX-output-file argument. -h help: print this message """ @@ -65,7 +65,7 @@ if len(args) == 1: if splitTables: xmlPath = path else: - xmlPath = path + '.xml' + xmlPath = path + '.ttx' elif len(args) == 2: ttPath, xmlPath = args else: diff --git a/ttffile.reg b/ttffile.reg index a5f815ca0..0b0709821 100644 --- a/ttffile.reg +++ b/ttffile.reg @@ -1,14 +1,14 @@ REGEDIT4 -[HKEY_CLASSES_ROOT\ttffile\shell\Convert to XML] +[HKEY_CLASSES_ROOT\ttffile\shell\Convert to TTX] @="Convert to XML" [HKEY_CLASSES_ROOT\ttffile\shell\Convert to XML\command] -@="start.exe \"C:\\Program Files\\f\\TTX\\tt2xml.py\" \"%1\"" +@="start.exe \"C:\\Program Files\\f\\TTX\\ttDump.py\" \"%1\"" [HKEY_CLASSES_ROOT\xmlfile\shell\Convert to TTF] @="Convert to TrueType font" [HKEY_CLASSES_ROOT\xmlfile\shell\Convert to TTF\command] -@="start.exe \"C:\\Program Files\\f\\TTX\\xml2tt.py\" \"%1\"" +@="start.exe \"C:\\Program Files\\f\\TTX\\ttCompile.py\" \"%1\"" diff --git a/xml2tt.py b/xml2tt.py deleted file mode 100644 index 4ec866683..000000000 --- a/xml2tt.py +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/env python - -"""\ -usage: %s [-hvb] [-i TrueType-input-file] XML-file [TrueType-output-file] - Translate an XML file (as output by tt2xml.py) to a TrueType font file. - If the XML-file argument is a directory instead of a file, all files - ending in '.xml' will be merged into one TrueType file. This is mostly - useful in conjunction with the -s option of tt2xml.py. - - Options: - -i TrueType-input-file: specify a TT file to be merged with the XML file(s) - -v verbose: messages will be written to stdout about what is being done - -b Don't recalc glyph boundig boxes: use the values in the XML file as-is. - -h help: print this message -""" -import sys, os, getopt -from fontTools import ttLib - -options, args = getopt.getopt(sys.argv[1:], "hvi:b") - -verbose = 0 -ttInFile = None -recalcBBoxes = 1 -for option, value in options: - if option == "-i": - ttInFile = value - elif option == "-v": - verbose = 1 - elif option == "-h": - print __doc__ % sys.argv[0] - sys.exit(0) - elif option == "-b": - recalcBBoxes = 0 - -if len(args) == 1: - xmlPath = args[0] - name, ext = os.path.splitext(xmlPath) - ttPath = name + '.ttf' -elif len(args) == 2: - xmlPath, ttPath = args -else: - print __doc__ % sys.argv[0] - sys.exit(2) - -tt = ttLib.TTFont(ttInFile, recalcBBoxes=recalcBBoxes, verbose=verbose) - -if os.path.isdir(xmlPath): - import glob - oldDir = os.getcwd() - os.chdir(xmlPath) - files = glob.glob("*.xml") - os.chdir(oldDir) - for xmlFile in files: - xmlFile = os.path.join(xmlPath, xmlFile) - tt.importXML(xmlFile) -else: - tt.importXML(xmlPath) -tt.save(ttPath) -del tt -if verbose: - import time - print "%s finished at" % sys.argv[0], time.strftime("%H:%M:%S", time.localtime(time.time()))