[MacRuby-devel] How to set up and retrieve returned buffer from CTFrameGetLineOrigins?

Paul Howson paul-lists at tdgq.com.au
Thu May 6 21:24:03 PDT 2010


On 07/05/2010, at 1:03 PM, Laurent Sansonetti wrote:

> Hi Paul,
> 
> You're right, the Pointer class must be used. Sorry about the lack of documentation. Here is a snippet that might work:
> 
> # n must be defined
> origins = Pointer.new(CGPoint.type, n) # this builds a pointer to n times CGPoint
> CTFrameGetLineOrigins(frame, CFRange.new(0, n), origins)
> 
> Using Pointer#[] you can simply dereference a given slot in the pointer, as in C.
> 
> n.times { |i| p origins[i] } # should print nth points
> 
> Let me know if this works or not for you.
> 
> Laurent

Thanks Laurent. I will try it out.

Paul



More information about the MacRuby-devel mailing list