from fontTools import ttLib
from fontTools.ttLib import ttFont, tables
import array
currentFont = ttLib.TTFont("Elstob[GRAD,opsz,wght].ttf")
for g_name in currentFont['glyf'].glyphs:
glyph = currentFont['glyf'][g_name]
if hasattr(glyph, 'program'):
glyph.program.fromAssembly("")
def install_glyph_program(nm, fo, asm):
g = fo['glyf'][nm]
g.program = tables.ttProgram.Program()
g.program.fromAssembly(asm)
currentFont['cvt '] = ttFont.newTable('cvt ')
setattr(currentFont['cvt '],'values',array.array('h', [891, 914, 74, 1487, 85, 39, 0, -23]))
currentFont['fpgm'] = ttFont.newTable('fpgm')
currentFont['fpgm'].program = tables.ttProgram.Program()
currentFont['fpgm'].program.fromAssembly('PUSHB[ ]\n\
0\n\
FDEF[ ]\n\
PUSHB[ ]\n\
0\n\
POP[ ]\n\
ENDF[ ]')
currentFont['prep'] = ttFont.newTable('prep')
currentFont['prep'].program = tables.ttProgram.Program()
currentFont['prep'].program.fromAssembly('\n\
PUSHB[ ]\n\
1\n\
POP[ ]')
install_glyph_program("a", currentFont, "SVTCA[0]\n\
PUSHB[ ]\n\
34\n\
1\n\
MIAP[1]")
currentFont['maxp'].maxTwilightPoints = 25
currentFont['maxp'].maxStorage = 70
currentFont['maxp'].maxStackElements = 256
currentFont['maxp'].maxFunctionDefs = 4
currentFont.save("Elstob[GRAD,opsz,wght]-hinted.ttf", 1)