def makeTestGlyph(): # make a simple glyph that we can test the pens with. from robofab.objects.objectsRF import RGlyph testGlyph = RGlyph() testGlyph.name = "testGlyph" testGlyph.width = 1000 pen = testGlyph.getPen() pen.moveTo((100, 100)) pen.lineTo((900, 100)) pen.lineTo((900, 800)) pen.lineTo((100, 800)) # a curve pen.curveTo((120, 700), (120, 300), (100, 100)) pen.closePath() return testGlyph
if __name__ == "__main__": """ beginPath ((112, 651), 'line', False, None) ((112, 55), 'line', False, None) ((218, 55), 'line', False, None) ((218, 651), 'line', False, None) endPath """ # a test from robofab.objects.objectsRF import RGlyph g = RGlyph() p = g.getPen() p.moveTo((112, 651)) p.lineTo((112, 55)) p.lineTo((218, 55)) p.lineTo((218, 651)) p.closePath() print g, len(g) digestPen = DigestPointPen() g.drawPoints(digestPen) print print "getDigest", digestPen.getDigest()
#FLM: 010 FontLab to RoboFab and Back # In which an adventurous glyph of your choice # makes a trip into RoboFab land, # and returns safely home after various inspections # and modifications. from robofab.world import CurrentGlyph, CurrentFont c = CurrentGlyph() f = CurrentFont() from robofab.objects.objectsRF import RGlyph d = RGlyph() # woa! d is now a rf version of a fl glyph! d.appendGlyph(c) d.width = 100 c.printDump() d.printDump() e = f.newGlyph('copyTest') # dump the rf glyph back to a fl glyph! e.appendGlyph(d) # see, it still takes its own kind as well e.appendGlyph(f['a']) e.printDump()