• 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: Ricky Sharp <email@hidden>
  • Date: Fri, 21 Apr 2006 17:13:49 -0500


On Apr 21, 2006, at 3:48 PM, Ivan Kourtev wrote:

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?

See <http://developer.apple.com/documentation/Cocoa/Conceptual/ FontHandling/Tasks/GettingFontMetrics.html>


which is also referred by Andreas Mayer's cool site:

<http://www.harmless.de/cocoa.html#fontmetrics>

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)?

You really don't have to worry about the baseline at all in this case. The letters lowercase-a, lowercase-y, and uppercase-e-acute will physically appear to have different heights, but their bounding box for a given font (face, size, etc.) will be the same. So just line up the bottom/top edges of those boxes and your text will render correctly.


___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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


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>)
 >Re: Getting exact height of NSAttributedString (From: Ivan Kourtev <email@hidden>)

  • Prev by Date: Re: Accessing Cocoa instance variables from C functions
  • Next by Date: Re: Finding all apps for
  • Previous by thread: Re: Getting exact height of NSAttributedString
  • Next by thread: Modify NSMenu font
  • Index(es):
    • Date
    • Thread