• 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
Re: Getting exact height of NSAttributedString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting exact height of NSAttributedString


  • Subject: Re: Getting exact height of NSAttributedString
  • From: Ivan Kourtev <email@hidden>
  • Date: Fri, 21 Apr 2006 16:48:51 -0400

On Apr 21, 2006, at 4:16 PM, Ricky Sharp wrote:


On Friday, April 21, 2006, at 02:58PM, Ivan Kourtev <email@hidden> wrote:


To me, the boundingRectWithSize:options: method is still completely
incomprehensible as well (not to mention that its documentation omits
important details).

I settled for the size method.  The only "complaint" I have is that
size: seems to return a bounding box that will accommodate glyphs
extending below and much above the baseline (even if such glyphs are
not present).  So in other words, it seems to me that size will
return the about the same bounding box (at least in the vertical
direction) for "cara" as it will for say 'Agap'

This is a good thing. I currently use size to vertically center text in custom controls/views. Not all strings will have acenders/ decenders, so it's important that they will have their centers all vertically aligned.


I knew that. I don't use these methods very often but always wondered - how do you tell where the baseline is?

Say you invoked size: and it gave you a certain box as a result and the string in question doesn't have any ascenders. If you wanted to line it up, how do you tell where the baseline is? Or am I thinking the wrong way about it (and one should never have to line up their own strings but leave this job to the text view)?

--
ivan




One thing about size that isn't good (I have a bug filed against this) is that it doesn't take shadow metrics into account. My code employs a workaround where I add a bit to the right and bottom edges based on shadow offset and blur values. I often draw my strings into NSImages. When I used to create images based solely upon size, my shadows were getting cut off.


But I still use the original size for positioning (horizontal and/ or vertical centering). This is because I want to align the text "content" and not necessarily any drop shadows.

--
Rick Sharp
Instant Interactive(tm)

_______________________________________________ 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: Getting exact height of NSAttributedString
      • From: Ricky Sharp <email@hidden>
References: 
 >Re: Getting exact height of NSAttributedString (From: "Shawn Erickson" <email@hidden>)
 >Re: Getting exact height of NSAttributedString (From: Ivan Kourtev <email@hidden>)
 >Re: Getting exact height of NSAttributedString (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Accessing Cocoa instance variables from C functions
  • Next by Date: Re: Accessing Cocoa instance variables from C functions
  • Previous by thread: Re: Getting exact height of NSAttributedString
  • Next by thread: Re: Getting exact height of NSAttributedString
  • Index(es):
    • Date
    • Thread