• 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: Questiong on NSString sizeWithAttributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questiong on NSString sizeWithAttributes


  • Subject: Re: Questiong on NSString sizeWithAttributes
  • From: Ed Voas <email@hidden>
  • Date: Wed, 09 Nov 2005 11:23:07 -0800

Hi Aki,

Yeah, I figured it was something like that. I just wasn't sure if maybe I was able to set something which would affect the typesetting behavior. Unfortunately we need this to work on Panther too. I did glance at the NSLayoutManager stuff, but it seemed like more than I wanted to get into at this stage of our project. I'm sure we'll revisit this in the future.

Thanks again,

-- Ed

Aki Inoue wrote:

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
References: 
 >Questiong on NSString sizeWithAttributes (From: Ed Voas <email@hidden>)
 >Re: Questiong on NSString sizeWithAttributes (From: Uli Kusterer <email@hidden>)
 >Re: Questiong on NSString sizeWithAttributes (From: Ed Voas <email@hidden>)
 >Re: Questiong on NSString sizeWithAttributes (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: NSOpenPanel and showing file name's
  • Next by Date: Re: NSOpenPanel and showing file name's
  • Previous by thread: Re: Questiong on NSString sizeWithAttributes
  • Next by thread: Re: Questiong on NSString sizeWithAttributes
  • Index(es):
    • Date
    • Thread