diff options
Diffstat (limited to 'src/silfont/scripts/psffixffglifs.py')
-rw-r--r-- | src/silfont/scripts/psffixffglifs.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/silfont/scripts/psffixffglifs.py b/src/silfont/scripts/psffixffglifs.py new file mode 100644 index 0000000..58b9759 --- /dev/null +++ b/src/silfont/scripts/psffixffglifs.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +__doc__ = '''Make changes needed to a UFO following processing by FontForge. +''' +__url__ = 'https://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2019 SIL International (https://www.sil.org)' +__license__ = 'Released under the MIT License (https://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() |