On 13/05/2009, at 7:16 AM, Dave Keck wrote:

text rects. Has anyone come up with a very fast way to estimate the size of
some text, more importantly the vertical size given a width.

You didn't mention that you tried NSAttributedString (specifically,
its -size method.) Does it suit your needs, or is it what you consider
too slow?


The -size method assumes the text is laid out on one line, so the height it returns is the line height. Even then it's usually pretty inaccurate - I've found it typically underestimates the necessary space by about 25% in each dimension, though it depends on the exact fonts the string is using.

The methods in NSLayoutManager are the best way to accurately measure text, as the OP is already doing.

You might be able to speed things up by keeping the layout manager around so that the information it caches is not destroyed every time.

--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