• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Questiong on NSString sizeWithAttributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Questiong on NSString sizeWithAttributes
      • From: Uli Kusterer <email@hidden>
    • Re: Questiong on NSString sizeWithAttributes
      • From: "John C. Randolph" <email@hidden>
    • Re: Questiong on NSString sizeWithAttributes
      • From: Stephane Sudre <email@hidden>
  • Prev by Date: Re: Memory not being freed
  • Next by Date: Re: Questiong on NSString sizeWithAttributes
  • Previous by thread: Re: Data-loss issue when quitting a CoreData-document-based application
  • Next by thread: Re: Questiong on NSString sizeWithAttributes
  • Index(es):
    • Date
    • Thread