Debian Codegraph @

sources/add_dsig.py

raw symbols SCIP
1 from fontTools import ttLib
2 from fontTools.ttLib import ttFont, tables
3 import argparse
4
5 # Just clipped out of gftools, where it has gone non-functional.
6
7 def add_dummy_dsig(ttFont):
8 """Add a dummy dsig table to a font. Older versions of MS Word
9 require this table.
10
11 Args:
12 ttFont: a TTFont instance
13 """
14 newDSIG = ttLib.newTable("DSIG")
15 newDSIG.ulVersion = 1
16 newDSIG.usFlag = 0
17 newDSIG.usNumSigs = 0
18 newDSIG.signatureRecords = []
19 ttFont.tables["DSIG"] = newDSIG
20
21 argparser = argparse.ArgumentParser(prog='add_dsig',
22 description='Add dummy DSIG table to a font.')
23 argparser.add_argument("inputfont", help='The font to process.')
24 args = argparser.parse_args()
25
26 inputfont = args.inputfont
27
28 thisFont = ttLib.TTFont(inputfont)
29 add_dummy_dsig(thisFont)
30 thisFont.save(inputfont, 1)