Re: Space Required By Text
Re: Space Required By Text
- Subject: Re: Space Required By Text
- From: Andrew Pinski <email@hidden>
- Date: Wed, 30 May 2001 17:51:01 -0400 (EDT)
>
On Wed, 30 May 2001, David Remahl wrote:
>
>
> No, actually it would not...I really do need the full rect, including
>
> the height of the text...
>
>
I forgot, actually NSSize works with floats:
>
>
>
float textWidth, textHeight;
>
>
textWidth = [@"your string" sizeWithAttributes:yourDict].width;
>
>
textHeight = [@"your string" sizeWithAttributes:yourDict].height;
One thing I would do instead of calling the same thing twice is
NSSize textWH = [@"your string" sizeWithAttributes:yourDict];
float textWidth, textHeight;
textWidth = textWH.width;
textHeight = textWH.height;
This of course will speed up the code by how much is unknown to me.
Thanks,
Andrew Pinski
>
>
>
Unless I misunderstand your needs, this would give you the height and
>
width of the rect your text would occupy!