Re: Sizing text in a box
Re: Sizing text in a box
- Subject: Re: Sizing text in a box
- From: Douglas Davidson <email@hidden>
- Date: Tue, 5 Feb 2002 16:56:34 -0800
On Tuesday, February 5, 2002, at 04:28 PM, email@hidden wrote:
I'm using -[NSAttributedString drawInRect:] to draw a string in a
rect (surprisingly enough :->). I'd like to have the text aligned to
the *bottom* of the rect, though, and I'm a bit flummoxed. There is no
attribute or paragraph style I can find that achieves this.
So I think I have to make my rect be the right height, such that
aligned to the top is the same thing as aligned to the bottom.
However, I don't know how many lines my text will be when wrapped into
the rect, and -[NSAttributedString size] doesn't take a rect -- it
seems to assume an un-wrapped layout. I can't find a simple way to do
this -- it looks like I have to bust out NSLayoutManager. Which I know
how to do, but -- ugh! Is there really no way to find out the extent
my text will draw to before I actually draw it?
I have a feeling I'm just missing the obvious, but I searched all the
Cocoa headers for methods returning NSSize and didn't hit pay dirt...
No, you aren't missing anything. This is an omission; on the other
hand, using NSLayoutManager will do this and much more, and furthermore
will be more efficient if you are first sizing and then drawing.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.