Questiong on NSString sizeWithAttributes
Questiong on NSString sizeWithAttributes
- Subject: Questiong on NSString sizeWithAttributes
- From: Ed Voas <email@hidden>
- Date: Tue, 8 Nov 2005 08:54:36 -0800
Hi,
I'm seeing something strange, and maybe I'm doing something wrong. I
have two text objects I'm trying to draw and need to position them
exactly. Both are being drawn in Arial Bold. One is 16pt and the
other is 12.
When I ask for the 16pt height via sizeWithAttributes, I'm told it
has a height of 18. Seems reasonable given the font ascent/descent.
But when I ask for the 12 point type height, I get... 18. This time,
it's not so cool. In theory I should be getting a height of about 13
or 14. This is causing me to position my text (in this specific case)
4 pixels off from where it should be. The font reports the line
height to be 14 for the 12 point text, btw, which sounds right. Yet
sizeWithAttributes reports 18.
I use the height to build my rectangle for my view. But we specify
our text items via baseline. So when given a value of 20, say, I
normally get the text ascent, subtract that and get the top and then
add the height for the bottom (this is in top-left-speak, even in
bottom left the same ideas apply). If I draw the text with a
background color I get 4 pixels of color where none should (in my
mind) appear.
Is this something that is either me doing something wrong, or is
there something else afoot here?
-- Ed
_______________________________________________
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