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 /examples/FTaddEmptyOT.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 'examples/FTaddEmptyOT.py')
-rw-r--r-- | examples/FTaddEmptyOT.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/examples/FTaddEmptyOT.py b/examples/FTaddEmptyOT.py new file mode 100644 index 0000000..46319ac --- /dev/null +++ b/examples/FTaddEmptyOT.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +'Add empty Opentype tables to ttf font' +__url__ = 'https://github.com/silnrsi/pysilfont' +__copyright__ = 'Copyright (c) 2014 SIL International (https://www.sil.org)' +__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)' +__author__ = 'Martin Hosken' + +from silfont.core import execute +from fontTools import ttLib +from fontTools.ttLib.tables import otTables + +argspec = [ + ('ifont',{'help': 'Input font file'}, {'type': 'infont'}), + ('ofont',{'help': 'Output font file','nargs': '?' }, {'type': 'outfont'}), + ('-l','--log',{'help': 'Log file'}, {'type': 'outfile', 'def': '_conv.log'}), + ('-s','--script',{'help': 'Script tag to generate [DFLT]', 'default': 'DFLT', }, {}), + ('-t','--type',{'help': 'Table to create: gpos, gsub, [both]', 'default': 'both', }, {}) ] + +def doit(args) : + font = args.ifont + args.type = args.type.upper() + + for tag in ('GSUB', 'GPOS') : + if tag == args.type or args.type == 'BOTH' : + table = ttLib.getTableClass(tag)() + t = getattr(otTables, tag, None)() + t.Version = 1.0 + t.ScriptList = otTables.ScriptList() + t.ScriptList.ScriptRecord = [] + t.FeatureList = otTables.FeatureList() + t.FeatureList.FeatureRecord = [] + t.LookupList = otTables.LookupList() + t.LookupList.Lookup = [] + srec = otTables.ScriptRecord() + srec.ScriptTag = args.script + srec.Script = otTables.Script() + srec.Script.DefaultLangSys = None + srec.Script.LangSysRecord = [] + t.ScriptList.ScriptRecord.append(srec) + t.ScriptList.ScriptCount = 1 + t.FeatureList.FeatureCount = 0 + t.LookupList.LookupCount = 0 + table.table = t + font[tag] = table + + return font + +def cmd() : execute("FT",doit, argspec) +if __name__ == "__main__": cmd() |