summaryrefslogtreecommitdiffstats
path: root/lib/silfont/scripts/psfnormalize.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/silfont/scripts/psfnormalize.py')
-rwxr-xr-xlib/silfont/scripts/psfnormalize.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/silfont/scripts/psfnormalize.py b/lib/silfont/scripts/psfnormalize.py
new file mode 100755
index 0000000..82b132e
--- /dev/null
+++ b/lib/silfont/scripts/psfnormalize.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+__doc__ = '''Normalize a UFO and optionally convert between UFO2 and UFO3'''
+__url__ = 'http://github.com/silnrsi/pysilfont'
+__copyright__ = 'Copyright (c) 2015 SIL International (http://www.sil.org)'
+__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)'
+__author__ = 'David Raymond'
+
+from silfont.core import execute
+
+argspec = [
+ ('ifont',{'help': 'Input font file'}, {'type': 'infont'}),
+ ('ofont',{'help': 'Output font file','nargs': '?' }, {'type': 'outfont'}),
+ ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': '_normalize.log'}),
+ ('-v','--version',{'help': 'UFO version to convert to (2, 3 or 3ff)'},{})]
+
+def doit(args) :
+
+ if args.version is not None :
+ v = args.version.lower()
+ if v in ("2","3","3ff") :
+ if v == "3ff": # Special action for testing with FontForge import
+ v = "3"
+ args.ifont.outparams['format1Glifs'] = True
+ args.ifont.outparams['UFOversion'] = v
+ else:
+ args.logger.log("-v, --version must be one of 2,3 or 3ff", "S")
+
+ return args.ifont
+
+def cmd() : execute("UFO",doit, argspec)
+if __name__ == "__main__": cmd()