diff options
author | Daniel Baumann <daniel@debian.org> | 2024-11-21 15:00:40 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-11-21 15:00:40 +0100 |
commit | 012d9cb5faed22cb9b4151569d30cc08563b02d1 (patch) | |
tree | fd901b9c231aeb8afa713851f23369fa4a1af2b3 /src/silfont/scripts/psffixffglifs.py | |
parent | Initial commit. (diff) | |
download | pysilfont-012d9cb5faed22cb9b4151569d30cc08563b02d1.tar.xz pysilfont-012d9cb5faed22cb9b4151569d30cc08563b02d1.zip |
Adding upstream version 1.8.0.upstream/1.8.0upstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
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() |