Re: Getting exact height of NSAttributedString
Re: Getting exact height of NSAttributedString
- Subject: Re: Getting exact height of NSAttributedString
- From: Ricky Sharp <email@hidden>
- Date: Fri, 21 Apr 2006 15:16:50 -0500
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.
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