Re: boundingRectWithSize:Option: and height constraint
Re: boundingRectWithSize:Option: and height constraint
- Subject: Re: boundingRectWithSize:Option: and height constraint
- From: Kyle Sluder <email@hidden>
- Date: Wed, 11 Nov 2009 23:19:29 -0800
On Wed, Nov 11, 2009 at 10:31 AM, Bill Cheeseman <email@hidden> wrote:
> Well, it is sometimes useful to be able to get the bounding rect that a string will have after it is laid out and wrapped to a specified constraint size, such as a fixed width but an open-ended height. For example, when I create a printing view I specify NSZeroRect for the initial frame, then in the printing view itself I reset the frame to the bounding rect every time the user changes print panel settings that affect the size. As Matt points out, I can do all that with text layout, but I'm looking for shortcuts.
Possible explanation (of course with the caveat that I don't work for
Apple): the expectation might be that you will be clipping drawing to
at most whatever rect you've passed in to
-boundingRectWithSize:options:attributes: anyway. Since
NSStringDrawing needs to set up an entire text system to return you
the result of this method, it might want to take advantage of this
common use case so it can do some optimization. Perhaps whatever
NSLayoutManager it is using has cached the layout of this string
already and can just return that, as long as the width of the rect
hasn't changed. Or maybe the vertically-unbounded case is just
super-super-optimized.
Which leads to the question: have you a demonstrated performance need
to make a shortcut here? If so, you probably shouldn't be using
NSStringDrawing anyway; it does a lot of temporary setup and takedown.
Sure, for the sake of correctness, or leading-squishing-to-fit, or
even future vertical writing direction support, there should be a way
to restrict the vertical dimension.
As for right now, you might want to consider whether it really matters to you.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden