| 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 ("[Klee One] Generating TTFs") |
| 8 |
for source in Path("sources").glob("*.glyphs"): |
| 9 |
__main__.main(("-g",str(source), "-o","ttf",)) |
| 10 |
|
| 11 |
for font in Path("master_ttf").glob("*.ttf"): |
| 12 |
modifiedFont = TTFont(font) |
| 13 |
print ("["+str(font).split("/")[1][:-4]+"] Adding stub DSIG") |
| 14 |
modifiedFont["DSIG"] = newTable("DSIG") #need that stub dsig |
| 15 |
modifiedFont["DSIG"].ulVersion = 1 |
| 16 |
modifiedFont["DSIG"].usFlag = 0 |
| 17 |
modifiedFont["DSIG"].usNumSigs = 0 |
| 18 |
modifiedFont["DSIG"].signatureRecords = [] |
| 19 |
if "SemiBold" in str(font): |
| 20 |
modifiedFont["OS/2"].usWeightClass = 600 #it is not being set correctly in the SemiBold weight :/ |
| 21 |
|
| 22 |
print ("["+str(font).split("/")[1][:-4]+"] Making other changes") |
| 23 |
modifiedFont["head"].flags |= 1 << 3 #sets flag to always round PPEM to integer |
| 24 |
modifiedFont["name"].addMultilingualName({'ja':'クレー One'}, modifiedFont, nameID = 1, windows=True, mac=False) |
| 25 |
if "SemiBold" in str(font): |
| 26 |
modifiedFont["name"].addMultilingualName({'ja':'SemiBold'}, modifiedFont, nameID = 2, windows=True, mac=False) |
| 27 |
elif "Regular" in str(font): |
| 28 |
modifiedFont["name"].addMultilingualName({'ja':'Regular'}, modifiedFont, nameID = 2, windows=True, mac=False) |
| 29 |
modifiedFont.save("fonts/ttf/"+str(font).split("/")[1]) |
| 30 |
|
| 31 |
shutil.rmtree("instance_ufo") |
| 32 |
shutil.rmtree("master_ufo") |
| 33 |
shutil.rmtree("master_ttf") |
| 34 |
|
| 35 |
for font in Path("fonts/ttf/").glob("*.ttf"): |
| 36 |
print ("["+str(font).split("/")[2][:-4]+"] Autohinting") |
| 37 |
fontName = str(font) |
| 38 |
hintedName = fontName[:-4]+"-hinted.ttf" |
| 39 |
subprocess.check_call( |
| 40 |
[ |
| 41 |
"ttfautohint", |
| 42 |
"--stem-width", |
| 43 |
"nsn", |
| 44 |
fontName, |
| 45 |
hintedName, |
| 46 |
] |
| 47 |
) |
| 48 |
|
| 49 |
shutil.move(hintedName, fontName) |