Subject: Re: [BUG?] - [NSLayoutManager
usedRectForTextContainer:] returns incorrect value

On Mar 30, 2009, at 3:55 PM, Benjamin Stiglitz wrote:

I'm running the code below. I have a single NSWindow with a checkbox and
a button. In the awakeFromNib method of the main controller, I change the
attribute of the checkbox string. In the compute: method, I compute the
height requested to display a string for a specific font and maximum

If I run this code as is, I get 17.0 as the required height. That's

If I comment the awakeFromNib code, I get 34.0f as the required height.
That's correct.

Is this the code exactly as it is in the app? e.g. compute: doesn't
depend in any way on the values you set in -awakeFromNib? (I think this
is your complaint, but I'm just verifying.)


Not that this fixes your problem, but -[NSAttributedString boundingRectWithSize:options:] would probably be a
bit easier for you to use.

I tried it. It apparently does not work for multi-line text.

I should probably add that additional tests show that the bug appears in Mac OS X 10.4.11 but not in Mac OS X 10.5.6.

I also thought of a ugly workaround (strike the text with a bezier path instead of relying on the Cocoa Text Engine) but if there is a better solution, I'm still interested.


Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)

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

Help/Unsubscribe/Update your Subscription:

This email sent to maillists@xxxxxxxxx