nearestPointOnPath_pathTime_ spectacularly wrong with Quadratic curves

I’m trying to write a script which uses nearestPointOnPath_pathTime_ but when testing I got bizarrely wrong answers. Here’s aKaf.medi from Khaled’s Amiri font.


In the Macro window, type:

Layer = Glyphs.font.selectedLayers[0]
print(Layer.paths[0].nearestPointOnPath_pathTime_(NSMakePoint(564,0), None))


(<NSPoint x=551.0 y=731.0>, 26.0)

Converting to Cubic makes it work.

One workaround would be to duplicate the path and convert to cubic in script before running nearestPointOnPath_pathTime_ on it but I am not sure how to do that.

I’m working on adding support for TrueType in those functions. You don’t happen to have some good TrueType math functions laying around :wink:

1 Like

If it’s not in I don’t know how to do it. :slight_smile:
Any way to convert to cubic from Python?


1 Like

Well that was easy. :slight_smile: Thanks.