On 03/06/2009, at 2:50 AM, Frank Canova wrote:

1) Each chunk of text will be a separate object that has to know how to draw itself.

2) The objects can be moved, rotated, skewew *without* layout by changing the CTM when drawing.

3) If the path is changed by moving a control point, the text should lay itself out again.

Giving each object its own NSTextView would be overkill, as well as interfering with other things that need to be drawn.

The obvious choice is to give each object its own NSTextStorage- >NSLayoutManager->NSTextContainer setup and use -[NSLayoutManager drawGlyphsForGlyphRange:atPoint:]

The NSTextStorage is clearly required and the NSTextContainer is pretty lightweight.

But how heavy is NSLayoutManager? It has a bunch of private objects so it's hard to judge from looking at the header file. Would it be a problem handing out several dozen of them?


Text-bearing objects in DrawKit do exactly this. In my case, I re-use the layout manager for all text, swapping its text storage as I go (I create a shared layout manager). This is not the result of any careful performance measurement however, just following some sample code I started with back in the day. The benefits are probably minor in terms of performance, since any caching of the layout that is done will be discarded when the text storage is switched.

You don't say what you think might be a problem - speed, memory use? I find that speed for my purposes is entirely adequate - I can interactively adjust objects that cause text re-layout and it keeps up with that no problem, even when the text is wrapping into an arbitrary- shaped path. Actual rendering speed of many, many text objects is also fine, and is dominated by the underlying glyph rendering as expected. Since that's the case I haven't been tempted to allocate one layout manager per object to gain the benefits of caching the layout - it doesn't figure prominently in the profile.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to