In PyObjC when the function is void I can pass None as the output argument and then I will get the output argument in the returned value but when it comes to a function that is non void I can't find an example how it's done. What I'm trying to do is to get the GlyphBuffer in the following function from an already initiated instance of a NSLayoutManager. Here is the syntax in Objective c:
NSInteger numGlyphs = [layoutManager numberOfGlyphs];
NSGlyph *glyphs = (NSGlyph *)malloc(sizeof(NSGlyph) * (numGlyphs + 1));
[layoutManager getGlyphs:glyphs range:NSMakeRange(0, numGlyphs)];
[textStorage removeLayoutManager:layoutManager];
As you can see the glyphs is an array of NSGlyphs with a length returned by layoutManager numberOfGlyphs. I got the following method to work in python:
layoutManager.getGlyphsInRange_glyphs_properties_characterIndexes_bidiLevels_ (glyphsRange, None, None, None, None)
But I don’t get the glyph buffer in return because the function is not void, instead it returns the number of glyphs in glyphBuffer as described here. The glyph buffer should be an UnsafeMutablePointer. I can’t find a way to pass a NSGlyph array to the second argument. When I pass a list I get a traceback:
ValueError: depythonifying 'pointer', got 'list'
Does anyone know if it’s possible and how it could be done?
Thanks
Since I was trying to extract position of glyphs in the LayoutManager I used locationForGlyphAtIndex method of the LayoutManager and it worked fine for my purpose.