# robothon06 # demo of executing python in FontLab, MacOS only # this script runs in the Python IDE # it will send some python code to FontLab # FontLab will execute the python code: # it will find the current glyph and send it to our other script. from robofab.tools.remote import runFontLabRemote, receiveGlyph from robofab.world import RFont # this is what we want FontLab to do: pythonCode = """ from robofab.world import CurrentGlyph from robofab.tools.remote import transmitGlyph g = CurrentGlyph() transmitGlyph(g) """ # this the font where we'll store the glyph from FontLab destFont = RFont() result = runFontLabRemote(pythonCode) receiveGlyph(result, destFont) print destFont.keys()
print runFontLabRemote(startNewFontCode) # send a glyph to FontLab, # it will be inserted in the CurrentFont. transmitGlyph(f['A']) f.removeGlyph('A') # send instructions to remove overlap for this glyph overlapCode = """from robofab.world import CurrentFont from robofab.tools.remote import transmitGlyph f = CurrentFont() f["A"].removeOverlap() f.update() transmitGlyph(f['A']) """ # send the code and catch the output x = runFontLabRemote(overlapCode) # interpret the output receiveGlyph(x, f) print "Number of contours after: ", len(f['A']) # send instructions to FontLab to close the font again. closeFontCode = """from robofab.world import CurrentFont f = CurrentFont() f.close(None) """ print runFontLabRemote(closeFontCode) print 'done!'