Hello all,
I'm trying to use the AppendAnchor command but I'm not sure I'm using it correctly. Bellow is my script running on Glyphs (I did all the import lines to see if my issue was a lack of modules, but in theory Glyphs should only require the first import):
--------------------------------------------------------------------------------
from objectsGS import *
from robofab.world import CurrentFont
from robofab.world import CurrentGlyph
from robofab.world import RFWorld
#f = CurrentFont()
#for g in f.selection:
# print g.anchors
# #appendAnchor("TOP", (525, g.width/2)
f = CurrentFont()
c = CurrentFont().selection
#print Glyphs.fonts
for g in c:
#print f[g]
#print len(f[g].anchors)
if len(f[g].anchors) == 0:
print f[g].name
print f[g].width
pt = (525, f[g].width/2)
f[g].appendAnchor("TOP", (100, 525))
--------------------------------------
I get the following output:
zero
656.0
Traceback (most recent call last):
File "<string>", line 27, in <module>
File "/Library/Python/2.6/site-packages/robofab/objectsGS.py", line 785, in appendAnchor
new = NewAnchor(name=name, pt=position )
NameError: global name 'NewAnchor' is not defined
I guess I'm not giving the position in the right format, but the RoboFab specification only states "appendAnchor(name, position)", so I'm not sure how to indicate it. Ultimately I'd want to center the anchor horizontally so rather than 100 I would use f[g].width/2 (as in the previous line). Can someone help me figure out how to use the appendAnchor command?
Thanks,
Bernardo