Implement writing output to arbitrary files including stdout.
Partially-fixes: http://sourceforge.net/p/fonttools/feature-requests/7/
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@614 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py
index b6cc184..695e8fd 100644
--- a/Lib/fontTools/ttx.py
+++ b/Lib/fontTools/ttx.py
@@ -15,6 +15,8 @@
-h Help: print this message
-d <outputfolder> Specify a directory where the output files are
to be created.
+ -o <outputfile> Specify a file to write the output to, use - for
+ standard output.
-v Verbose: more messages will be written to stdout about what
is being done.
-a allow virtual glyphs ID's on compile or decompile.
@@ -88,6 +90,7 @@
listTables = 0
outputDir = None
+ outputFile = None
verbose = 0
splitTables = 0
disassembleInstructions = 1
@@ -110,6 +113,8 @@
print "The -d option value must be an existing directory"
sys.exit(2)
self.outputDir = value
+ elif option == "-o":
+ self.outputFile = value
elif option == "-v":
self.verbose = 1
# dump options
@@ -242,7 +247,7 @@
def parseOptions(args):
try:
- rawOptions, files = getopt.getopt(args, "ld:vht:x:sim:baey:")
+ rawOptions, files = getopt.getopt(args, "ld:o:vht:x:sim:baey:")
except getopt.GetoptError:
usage()
@@ -270,7 +275,10 @@
print 'Unknown file type: "%s"' % input
continue
- output = makeOutputFileName(input, options.outputDir, extension)
+ if options.outputFile:
+ output = options.outputFile
+ else:
+ output = makeOutputFileName(input, options.outputDir, extension)
jobs.append((action, input, output))
return jobs, options