I'm not very good with robofab, but I wanted to select a node and create another node on top. Just in case I'm using fontlab 5 and have all the basic python plugins installed.
not completely sure why you would want to do this but anyway maybe this helps - quick and dirty made out of an older RoboFab script for FL - It worked when I used the square selection (not directly selecting a node) see image - the other image for indentation - still not sure if this is what you need - good luck!!
from robofab.world import CurrentGlyph, CurrentFont
Under Tools/Customize... you can enter your own key command for Duplicate Node. Alternatively, control-click on the node you want and Duplicate Node comes up in the pop-up menu. Still part of the contour. No need for a script. …Unless I am misunderstanding the context.
Based on what Lukas wrote above, this seems a bit brutalist but something in this direction (probably with some refinements) might do the trick. Not tested more than ten minutes. Things get a bit weird with curve points.
from robofab.world import CurrentGlyph, CurrentFont
g = CurrentGlyph()
for contour in g.contours: for i in range(0, len(contour.bPoints)): point = contour.bPoints[i] if point.selected: # print i contour.insertBPoint(i+1, point.type, point.anchor, point.bcpIn, point.bcpOut)
Why don't you use the Fontlab's native insert functionality as specified in Fontlab Unnoficial Guide: "... Insert (Node | Glyph | [Node]) | (Node | Glyph | [Node], nodeindex) - inserts Node, Glyph or sequence of Nodes at the begining of glyph's nodes or at specified node index..."
...i think it is far simpler or you need to code to be RoboFab-ed? The following siple code will duplicate the node and insert a straight/line segment between the two nodes:
Comments
quick and dirty made out of an older RoboFab script for FL - It worked when I used the square selection (not directly selecting a node) see image - the other image for indentation - still not sure if this is what you need - good luck!!
from robofab.world import CurrentGlyph, CurrentFont
But what I need is the node to be part of the contour, right now I get a separate node on the same place, it's close though.
I know it's very weird haha
On my version of fontlab 5.0.4, there is no Duplicate Node in the customize menu. And you can do only 1 at a time.
Which version are you using?
Thank you for helping me in my madness
PS: I love you work
"... Insert (Node | Glyph | [Node]) | (Node | Glyph | [Node], nodeindex) - inserts Node, Glyph or sequence of Nodes at the begining of glyph's nodes or at specified node index..."
...i think it is far simpler or you need to code to be RoboFab-ed? The following siple code will duplicate the node and insert a straight/line segment between the two nodes: