RoboFab getPen()


got a formerly working script, which is not working anymore. basically it uses the RoboFab getPen() like so:

from import CurrentFont
f = CurrentFont()
newGlyph = f.newGlyph('demoDrawGlyph', clear=True)
newGlyph.width = 1000
## here is an issue ##
pen = newGlyph.getPen()

pen.moveTo((100, 100))
pen.lineTo((800, 100))
pen.lineTo((100, 100))

It gets me:

ImportError: No module named GSPen

When I remove the parenthesis behind pen = newGlyph.getPen(), it runs further, but then I get: AttributeError: 'function' object has no attribute 'moveTo'

RoboFab itself seems to be working. It nicely creates a new Glyph with the proper name and width, it is empty though and got trouble with the moveTo guys. Also i just updated the from schriftgestalt.

(G1, G2, both cutting edge, Yosemite)


AFAIR, you need to import objectsGS. I got this to work:

from objectsGS import CurrentFont

f = CurrentFont()
g = f.newGlyph(‘demoDrawGlyph’, clear=True)
g.width = 1000

pen = g.getPen()
pen.moveTo((100, 100))
pen.lineTo((800, 100))
pen.lineTo((100, 800))



This should work. Do you have the latest version of robFab? It should import objectsGS for you.


Robofab is running on darwin, Python version: 2.7, Mac stuff: X, PC stuff: None, FontLab stuff: False, FLversion: None, Glyphs stuff: True, Glyphs version: 689, RoboFont stuff: False, RoboFont version: None


–> I wonder, because most RoboFab-distincive methods work perfectly.


The version is good. There is something else going on. I’m on a pretty new system and your initial script works fine so there is something else going on. Can you rename your plugin folder and restart Glyphs and see if the script works?


you mean the whole script folder? Will it still be recognized? (It doesn’t even work directly in the macro window, though)


Not the Script folder, the Plugin folder.


ok, so I:

  • renamed the Plugins folder
  • restarted G2
  • thus, most plugins where not available
  • tried my initial script in macro window
  • it makes the new Glyphs, but still gets me the error:

Traceback (most recent call last):
File "<string>", line 7, in <module> File "/Library/Python/2.7/site-packages/robofab/objects/", line 1442, in getPen ....return SegmentToPointPen(self.getPointPen()) File "/Users/Mark/Library/Application Support/Glyphs/Scripts/", line 606, in getPointPen ....from GSPen import GSPointPen ImportError: No module named GSPen

  • I renamed the Plugins folder back
  • thus, got my Plugins back
  • running the script from the macro window causes the same as with renamed Plugin folder

thanks so much for your help!


Perhaps delete the .pyc files in your Scripts folder, restart, and try again.


done, the same happens and it recreates the .pyc.


Do you have in your Scripts folder?
Do you have the latest versions?


You did your magic again! thanks so much!!

The was there, but (I don’t know why) in a folder, called »GSPen«, along with another and objectsGS.pyc

Looks like these 2 guys are sensitive and allergic against being put into folders.


here’s the thing :slight_smile:
make FontMetrics Glyph (@GitHub)