When you’re in text mode and you click the measurement tool somewhere within a glyph, a horizontal line appears with values representing the left and right distances from the glyph.
Is there a way to access those distance values through scripting? For example, you specify a height that you want to query, and it returns a list with those values?
I’m working on auto-kerning, and that data would be invaluable…
One issue: the result of the calculateIntersectionsForLayer_startPoint_endPoint_() function is a list of NSConcreteValue types instead of NSPoint types.
I’m not familiar with “Python/Cocoa” transition code… how do I access the NSConcreteValue’s x and y values?
…#this padding value is added to either side of the horizontal measuring line to ensure measurement is wider than layer.
…padding = 10.0
…#capture horizontal intersections from beyond leftmost part of layer to beyond rightmost part of layer.
…intersections = Measure.calculateIntersectionsForLayer_startPoint_endPoint_(layer, NSMakePoint(layer.LSB - padding, measurementHeight), NSMakePoint((layer.width - layer.RSB) + padding, measurementHeight))
…#if intersections contains more than two points, layer was intersected.
…if len(intersections) > 2:
…return (intersections[1].pointValue().x, layer.width - intersections[-2].pointValue().x)
…else:
…return None
And just out of curiosity… with the .alloc().init() calls here (and in other examples on this forum)… should there be a corresponding release call? How is memory managed when Python meets Objective-C? Is there a leak in the function I wrote?