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/psffixffglifs.py | |
parent | Initial commit. (diff) | |
download | pysilfont-da875fcb62c801b8d19b3d4d984ad963574fb356.tar.xz pysilfont-da875fcb62c801b8d19b3d4d984ad963574fb356.zip |
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/silfont/scripts/psffixffglifs.py')
-rwxr-xr-x | lib/silfont/scripts/psffixffglifs.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/silfont/scripts/psffixffglifs.py b/lib/silfont/scripts/psffixffglifs.py new file mode 100755 index 0000000..f496737 --- /dev/null +++ b/lib/silfont/scripts/psffixffglifs.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +__doc__ = '''Make changes needed to a UFO following processing by FontForge. +''' +__url__ = 'http://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2019 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': '_postff.log'})] + +def doit(args) : + + font = args.ifont + logger = args.logger + + advances_removed = 0 + unicodes_removed = 0 + for layer in font.layers: + if layer.layername == "public.background": + for g in layer: + glyph = layer[g] + # Remove advance and unicode fields from background layer + # (FF currently copies some from default layer) + if "advance" in glyph: + glyph.remove("advance") + advances_removed += 1 + logger.log("Removed <advance> from " + g, "I") + uc = glyph["unicode"] + if uc != []: + while glyph["unicode"] != []: glyph.remove("unicode",0) + unicodes_removed += 1 + logger.log("Removed unicode value(s) from " + g, "I") + + if advances_removed + unicodes_removed > 0 : + logger.log("Advance removed from " + str(advances_removed) + " glyphs and unicode values(s) removed from " + + str(unicodes_removed) + " glyphs", "P") + else: + logger.log("No advances or unicodes removed from glyphs", "P") + + return args.ifont + +def cmd() : execute("UFO",doit, argspec) +if __name__ == "__main__": cmd() |