Debian Codegraph @

build.py

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 from fontTools.ttLib.ttFont import newTable
2 from fontmake import __main__
3 from fontTools.ttLib import TTFont, newTable
4 import shutil, subprocess, glob
5 from pathlib import Path
6
7 print ("[Rampart] Generating TTFs")
8 __main__.main(("-g","sources/RampartOne.glyphs", "-o","ttf",))
9
10 for font in Path("master_ttf").glob("*.ttf"):
11 modifiedFont = TTFont(font)
12 print ("["+str(font).split("/")[1][:-4]+"] Adding stub DSIG")
13 modifiedFont["DSIG"] = newTable("DSIG") #need that stub dsig
14 modifiedFont["DSIG"].ulVersion = 1
15 modifiedFont["DSIG"].usFlag = 0
16 modifiedFont["DSIG"].usNumSigs = 0
17 modifiedFont["DSIG"].signatureRecords = []
18
19 print ("["+str(font).split("/")[1][:-4]+"] Making other changes")
20 modifiedFont["name"].addMultilingualName({'ja':'ランパート One'}, modifiedFont, nameID = 1, windows=True, mac=False)
21 modifiedFont["name"].addMultilingualName({'ja':'Regular'}, modifiedFont, nameID = 2, windows=True, mac=False)
22 modifiedFont["head"].flags |= 1 << 3 #sets flag to always round PPEM to integer
23
24 modifiedFont.save("fonts/ttf/"+str(font).split("/")[1])
25
•26 try:
27 shutil.rmtree("instance_ufo")
28 except Exception as e:
29 print(e)
30 try:
31 shutil.rmtree("master_ufo")
32 except Exception as e:
33 print(e)
34 try:
35 shutil.rmtree("master_ttf")
36 except Exception as e:
37 print(e)
38
39 for font in Path("fonts/ttf/").glob("*.ttf"):
40 print ("["+str(font).split("/")[2][:-4]+"] Autohinting")
41 fontName = str(font)
42 hintedName = fontName[:-4]+"-hinted.ttf"
43 subprocess.check_call(
44 [
45 "ttfautohint",
46 "--stem-width",
47 "nsn",
48 fontName,
49 hintedName,
50 ]
51 )
52
53 shutil.move(hintedName, fontName)