Re: Questiong on NSString sizeWithAttributes
Re: Questiong on NSString sizeWithAttributes
- Subject: Re: Questiong on NSString sizeWithAttributes
- From: Aki Inoue <email@hidden>
- Date: Wed, 9 Nov 2005 11:03:18 -0800
Ed,
This line height oddity in NSStringDrawing API is actually a known
issue.
Unlike standalone NSLayoutManager, the API (along with NSCell text
rendering logic) is still using
NSTypesetterBehavior_10_2_WithCompatibility for backward
compatibility reasons.
The setting employs some complex logic in determining the 'ideal'
line height which was optimized for handling Postscript fonts in DPS
environment.
We have a long-term plan to eliminate the issue, but we have to stage
it gradually (the change would break nearly all existing applications).
In the meanwhile, you can use the new NSStringDrawing API introduced
in Tiger that allows you to render text at baseline origin.
Aki
Hi,
Well, one of my other posts had some code in it that I distilled
down and just plopped into a brand new app to avoid any potential
side-effects. If you look back at that, you'll see that I just set
up a font and and set the attributes dictionary and call
sizeWithAttributes only to be greeted with height of 18. Very odd.
It's just wrong from the looks of things.
After spending much too long on this, I gave up and switched to
HITheme text measurement and rendering for now because we are
running out of time for what we're working on. Ideally I wouldn't
do that, but otoh, they're simple, fast, and seem to be reporting
the truth. I'll likely write a bug against sizeWithAttributes
unless someone can see something I'm missing or some other setting
someplace I need to set.
On Nov 9, 2005, at 1:06 AM, Uli Kusterer wrote:
Am 08.11.2005 um 17:54 schrieb Ed Voas:
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.
Ed,
I know you're a guru, so I doubt you'd make this mistake, but
since this goes into the archives and someone might google for a
similar problem:
Have you tried commenting out the 16pt code to check whether it
works then? Just to make sure you're not accidentally passing in
the wrong attributes dictionary twice without noticing, or
overwriting/replacing something.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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
_______________________________________________
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