diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-02 20:01:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-03-02 20:01:10 +0000 |
commit | da875fcb62c801b8d19b3d4d984ad963574fb356 (patch) | |
tree | 3d85503747c56c2a387b291524442946f4bebb73 /lib/silfont/scripts/psfexportpsnames.py | |
parent | Initial commit. (diff) | |
download | pysilfont-1f9ed76662986bf6e3802e9fb3080d61e5797532.tar.xz pysilfont-1f9ed76662986bf6e3802e9fb3080d61e5797532.zip |
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | lib/silfont/scripts/psfexportpsnames.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/silfont/scripts/psfexportpsnames.py b/lib/silfont/scripts/psfexportpsnames.py new file mode 100755 index 0000000..5995e14 --- /dev/null +++ b/lib/silfont/scripts/psfexportpsnames.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +__doc__ = '''Write mapping of glyph name to postscript name to a csv file +- csv format glyphname,postscriptname''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2016 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 +import datetime + +suffix = "_psnamesmap" +argspec = [ + ('ifont',{'help': 'Input font file'}, {'type': 'infont'}), + ('-o','--output',{'help': 'Ouput csv file'}, {'type': 'outfile', 'def': suffix+'.csv'}), + ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': suffix+'.log'}), + ('--nocomments',{'help': 'No comments in output files', 'action': 'store_true', 'default': False},{})] + +def doit(args) : + font = args.ifont + outfile = args.output + + # Add initial comments to outfile + if not args.nocomments : + outfile.write("# " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S ") + args.cmdlineargs[0] + "\n") + outfile.write("# "+" ".join(args.cmdlineargs[1:])+"\n\n") + + glyphlist = font.deflayer.keys() + missingnames = False + + for glyphn in glyphlist : + glyph = font.deflayer[glyphn] + # Find PSname if present + PSname = None + if "lib" in glyph : + lib = glyph["lib"] + if "public.postscriptname" in lib : PSname = lib["public.postscriptname"][1].text + if PSname: + outfile.write(glyphn + "," + PSname + "\n") + else : + font.logger("No psname for " + glyphn, "W") + missingnames = True + if missingnames : font.logger("Some glyphs had no psnames - see log file","E") + return + +def cmd() : execute("UFO",doit,argspec) +if __name__ == "__main__": cmd() |