From da875fcb62c801b8d19b3d4d984ad963574fb356 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 2 Mar 2023 21:01:10 +0100 Subject: Adding upstream version 1.6.0. Signed-off-by: Daniel Baumann --- examples/fontforge-old/FFdblEncode.py | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 examples/fontforge-old/FFdblEncode.py (limited to 'examples/fontforge-old/FFdblEncode.py') diff --git a/examples/fontforge-old/FFdblEncode.py b/examples/fontforge-old/FFdblEncode.py new file mode 100755 index 0000000..781267b --- /dev/null +++ b/examples/fontforge-old/FFdblEncode.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +'''FontForge: Double encode glyphs based on double encoding data in a file +Lines in file should look like: "LtnSmARetrHook",U+F236,U+1D8F''' +__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', 'def': 'new'}), + ('-i','--input',{'help': 'Input csv text file'}, {'type': 'infile', 'def': 'DblEnc.txt'}), + ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': 'DblEnc.log'})] + +def doit(args) : + font = args.ifont + inpf = args.input + logf = args.log +#Create dbl_encode list from the input file + dbl_encode = {} + for line in inpf.readlines() : + glyphn, pua_usv_str, std_usv_str = line.strip().split(",") # will exception if not 3 elements + if glyphn[0] in '"\'' : glyphn = glyphn[1:-1] # slice off quote marks, if present + pua_usv, std_usv = int(pua_usv_str[2:], 16), int(std_usv_str[2:], 16) + dbl_encode[glyphn] = [std_usv, pua_usv] + inpf.close() + + for glyph in sorted(dbl_encode.keys()) : + if glyph not in font: + logf.write("Glyph %s not in font\n" % (glyph)) + continue + g = font[glyph] + ousvs=[g.unicode] + oalt=g.altuni + if oalt != None: + for au in oalt: + ousvs.append(au[0]) # (may need to check variant flag) + dbl = dbl_encode[glyph] + g.unicode = dbl[0] + g.altuni = ((dbl[1],),) + logf.write("encoding for %s changed: %s -> %s\n" % (glyph, ousvs, dbl)) + logf.close() + return font + +def cmd() : execute("FF",doit,argspec) +if __name__ == "__main__": cmd() -- cgit v1.2.3