Skip to content

Instantly share code, notes, and snippets.

@charlesmchen
Created April 30, 2012 18:35
Show Gist options
  • Save charlesmchen/2560855 to your computer and use it in GitHub Desktop.
Save charlesmchen/2560855 to your computer and use it in GitHub Desktop.
Robofab NoneLab test
import os
import robofab.world
from ufo2fdk import haveFDK
from ufo2fdk import OTFCompiler
def process():
font = robofab.world.NewFont(familyName='testFamily', styleName='Roman')
font.info.ascender = 600
font.info.descender = -400
font.info.unitsPerEm = 1200
font.info.xHeight = 400
font.info.capHeight = 400
font.info.versionMajor = 1
font.info.versionMinor = 0
font.update()
font.info.fullName = font.info.familyName + '-' + font.info.styleName
font.info.fontName = font.info.fullName.replace(' ', '')
font.info.designer = 'Roberto Ungusto'
font.info.createdBy = 'Roberto Ungusto'
font.info.year = 2012
for letter in ('A', 'B', '1',):
glyph = font.newGlyph(letter)
glyph.unicode = ord(letter)
glyph.width = 200
glyph.leftMargin = 50
glyph.rightMargin = 50
glyphPen = glyph.getPen()
glyphPen.moveTo((344, 645))
glyphPen.lineTo((647, 261))
glyphPen.lineTo((662, -32))
glyphPen.lineTo((648, -61))
glyphPen.lineTo((619, -61))
glyphPen.lineTo((352, 54))
glyphPen.lineTo((72, 446))
glyphPen.lineTo((117, 590))
glyphPen.lineTo((228, 665))
glyphPen.closePath()
glyphPen.moveTo((99, 451))
glyphPen.lineTo((365, 74))
glyphPen.curveTo((359, 122), (376, 178), (420, 206))
glyphPen.curveTo((422, 203), (142, 579), (142, 579))
glyphPen.closePath()
glyphPen.moveTo((631, -32))
glyphPen.lineTo((629, 103))
glyphPen.curveTo((556, 111), (524, 71), (508, 20))
glyphPen.closePath()
glyph.update()
font.update()
dstFolder = os.path.abspath(os.path.join('ufo-out'))
print 'dstFolder', dstFolder
if not os.path.exists(dstFolder):
os.mkdir(dstFolder)
filename = font.info.fullName
dstFile = os.path.join(dstFolder, filename + '.ufo')
font.save(dstFile)
dstFile = os.path.join(dstFolder, filename + '.ttf')
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()
def main():
process()
if __name__ == "__main__":
main()
print
print 'complete.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment