Skip to content

Instantly share code, notes, and snippets.

@charlesmchen
Created May 10, 2012 21:28
Show Gist options
  • Save charlesmchen/2656019 to your computer and use it in GitHub Desktop.
Save charlesmchen/2656019 to your computer and use it in GitHub Desktop.
Robofab Write Otf Sample Logic
import os
import robofab.world
from ufo2fdk import haveFDK
from ufo2fdk import OTFCompiler
font = robofab.world.OpenFont('<path to ufo file>')
font.update()
font.autoUnicodes()
font.update()
dstFolder = os.path.abspath(os.path.join('..', 'data', 'ufo-out'))
print 'dstFolder', dstFolder
if not os.path.exists(dstFolder):
os.mkdir(dstFolder)
filename = font.info.fullName
dstFile = os.path.join(dstFolder, filename + '.otf')
print 'dstFile', dstFile
if haveFDK():
print "I found the FDK!"
else:
print "I'm sorry, I could not find the FDK."
compiler = OTFCompiler()
reports = compiler.compile(font, dstFile, checkOutlines=True, autohint=True)
print reports["checkOutlines"]
print reports["autohint"]
print reports["makeotf"]
font.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment