Generate node overlap with python?
Fernando Díaz
Posts: 133
Comments
-
(Actually, It would be duplicate nodes putting it in simple words).0
-
Hi @Fernando Díaz,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, CurrentFontg = CurrentGlyph()sel = []for contour in g.contours:for Point in contour.points:if Point.selected:sel.append(Point)if len(sel) != 0:xL = []yL = []#store up all coordinates for use laterfor Point in sel:x, y = Point.x, Point.yxL.append(x)yL.append(y)print sel, xL[0], yL[0]p = g.getPen()p.moveTo((xL[0], yL[0]))p.lineTo((xL[0], yL[0]))p.closePath()CurrentFont().update()
1 -
Hey @Lukas Schneider thank you!
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 haha0 -
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.0
-
Hey Dyana,
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?0 -
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)
CurrentFont().update()2 -
It works Nina!
Thank you for helping me in my madness
PS: I love you work
0 -
I'd like the opposite of this script where sometimes a nice single node curve becomes two overlapping nodes that cannot be merged
0 -
Ahh, I have FL 5.1.2, but I haven't used it in years, in case you were thinking of upgrading. Glad that Nina solved the problem.0
-
I just bought the new version, but haven't installed it yet0
-
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:from FL import *glyph = fl.glyphnodeIndex = 0while nodeIndex < len(glyph.nodes):if glyph[nodeIndex].selected:glyph.Insert(Node(nLINE, Point(glyph[nodeIndex].x, glyph[nodeIndex].y)), nodeIndex + 1)nodeIndex += 1
0
Categories
- All Categories
- 43 Introductions
- 3.7K Typeface Design
- 803 Font Technology
- 1K Technique and Theory
- 622 Type Business
- 444 Type Design Critiques
- 542 Type Design Software
- 30 Punchcutting
- 136 Lettering and Calligraphy
- 83 Technique and Theory
- 53 Lettering Critiques
- 485 Typography
- 303 History of Typography
- 114 Education
- 68 Resources
- 499 Announcements
- 80 Events
- 105 Job Postings
- 148 Type Releases
- 165 Miscellaneous News
- 270 About TypeDrawers
- 53 TypeDrawers Announcements
- 116 Suggestions and Bug Reports