summaryrefslogtreecommitdiffstats
path: root/lib/silfont/scripts/psfsetdummydsig.py
blob: 02896a0f4d72e4d11984bd4e30926618ce18504a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python3

__doc__ = 'Put a dummy DSIG table into a ttf font'
__url__ = 'http://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2019 SIL International (http://www.sil.org)'
__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)'
__author__ = 'Nicolas Spalinger'

from silfont.core import execute
from fontTools import ttLib

argspec = [
    ('-i', '--ifont', {'help': 'Input ttf font file'}, {}),
    ('-o', '--ofont', {'help': 'Output font file'}, {}),
    ('-l', '--log', {'help': 'Optional log file'}, {'type': 'outfile', 'def': 'dummydsig.log', 'optlog': True})]


def doit(args):

    ttf = ttLib.TTFont(args.ifont)

    newDSIG = ttLib.newTable("DSIG")
    newDSIG.ulVersion = 1
    newDSIG.usFlag = 0
    newDSIG.usNumSigs = 0
    newDSIG.signatureRecords = []
    ttf.tables["DSIG"] = newDSIG

    args.logger.log('Saving the output ttf file with dummy DSIG table', 'P')
    ttf.save(args.ofont)

    args.logger.log('Done', 'P')


def cmd(): execute("FT", doit, argspec)
if __name__ == '__main__': cmd()