Getting exact height of NSAttributedString
Getting exact height of NSAttributedString
- Subject: Getting exact height of NSAttributedString
- From: Ivan Kourtev <email@hidden>
- Date: Wed, 8 Feb 2006 14:11:23 -0500
Hello,
My application needs to draw a single-word NSAttributString as big as
possible but not exceeding a specific fitting rectangle. I use the
size method of NSAttributedString to find out whether at certain font
size the bounding box of the string exceeds the fitting rectangle --
this works fine.
However, I noticed that the size method returns a height which is
bigger than the actual height and accounts for the possibility that
some characters (such as 'g') can extend below the baseline. So, for
example, the NSAttributedString's "60" and "6g" have a bounding box
with the same height (according to the size method).
As my single-word strings are actually numbers and will _never_
contain characters that extend under the baseline, is there any way
to get the actual height of the string, without the under-the-
baseline adjustment? I looked into the suggested NSLayoutManager but
decided it was too heavyweight to use for my needs.
Is this a feature or a bug? Why not have three methods that return
BOOL -- whether there is a part of the string under the baseline
NSSize -- bounding box with the under-the-baseline adjustment (the
current size method)
float -- how much of the height is under the baseline
Or does this API exist and I am missing it?
Thanks,
-- ivan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden