My code snippet:
path = Glyphs.font.selectedLayers[0].paths[0]
print (path.segments[0])
The output is:
<RSegment line (0), r>
My question is: what is RSegment? Is there any document about the attributes and operations for it? Thanks.
My code snippet:
path = Glyphs.font.selectedLayers[0].paths[0]
print (path.segments[0])
The output is:
<RSegment line (0), r>
My question is: what is RSegment? Is there any document about the attributes and operations for it? Thanks.
A RSegment is part of the robofab API. Normally, path.segments return a glyph segment type. But when any script loads the robofab wrapper, this gets overwritten.
I would very strongly recommend to use path.nodes instead of segments. That gives you much more control and is also faster.
Thanks.
But I am still confused when trying to traverse the data. When a segment is a line, it could print the nodes. When a segment is a curve, the output is empty. This makes me wonder if there is anything wrong.
print Glyphs.font.selectedLayers[0].paths[0].segments[0]
print Glyphs.font.selectedLayers[0].paths[0].segments[0].points
A line:
<RSegment line (0), r>
[<GSNode x=565.0 y=687.0 qcurve>, <GSNode x=573.0 y=695.0 line>]
A curve:
<RSegment qcurve (0), r>
[]
Used
print Glyphs.font.selectedLayers[0].paths[0].nodes