Is GSPathSegment fully implemented?

I see a few properties listed here: Glyphs.app Python Scripting API Documentation — Glyphs.app Python Scripting API 3.0 documentation but only type seems available (wrapper is here)

Also it looks like it’s supposed to return two NSPoints if it’s a line and four if it’s a curve, but in a line the second two still get returned with this value: <NSPoint x=9.223372036854776e+18 y=0.0>

Ah it looks like they are an array so I will need to access e.g. shape.segments[0] rather than shape.segments

still, methods like points arent available

What are you trying to do?

Trying to recreate a glyph but using fontParts

Do you really need to use fontParts? It’s API collides to heavily with the Glyphs API (you have found that one of the more difficult places).
Do you write a new script, or trying to use an existing one?

I would prefer to if possible, the APIs being different hasn’t been a problem so far (it’s a new script). maybe I need to take a closer look at the difference between the way the two APIs think about segments

If you make a new script and mainly use Glyphs, I would use the Glyphs API directly. Even when fontParts would be full implemented, there are a lot things you can’t do with it.

I have tried several times to implement fontParts but the underlying concept is too different. e.g.: fontParts doesn’t understand multiple masters, and accessing extra layers is very complicated. And then there are some places where the Glyphs API is different as you found with the segments. This can’t be solved without making the native API worse. Or at least I don’t know how.

I agree - I do not want to try to build a whole abstraction for fontParts, I just want to build a glyph with fontParts for use outside Glyphs. I might be able to combine information from both GSNodes and GSPathSegments to make the fontParts segments

The robofab wrapper had an abstraction for this. robofab and fontparts in most parts use the same API. But I had a quick look at it and it probably doesn’t work any more.

Can you send me a sample script on how you would plan to use this?

As the .segments property is only derived from the GSPath.nodes, changing the segments will not result in changes to the underlying paths. It is used to get the “shape” (segments = path.segments), do something about it (internally it is mostly used in the Overlap removing code). Then build new paths from those segments and assign it back to the layer.

I wonder if it might be feasible to just build two helper methods, one that is targeting fontParts and on that is targeting the Glyphs API.

Oh I see. I don’t need the segments just to draw it, only the points. The APIs are pretty close for this purpose. Thanks for the pointers