• 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:Calculating the size of NSFont...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Calculating the size of NSFont...


  • Subject: Re:Calculating the size of NSFont...
  • From: Dale Miller <email@hidden>
  • Date: Sun, 4 Mar 2007 13:25:18 -0700

I asked the same question a couple of months ago and got zero response. However, i was able to find, by experiment, an answer which seems to work. Caveat: no documentation exists to verify this. In fact all the documentation contradicts it. However the actual behavior of the Apple typesetter contradicts the documentation, and agrees with my experiments, at least for the sizes and fonts I have tried. The following code works for me:

	float adv = [termFont advancementForGlyph:
		[termFont glyphWithName:@"space"]].width;
	charSize.width = (int)(adv+0.5);				/* font size must be < 17. */
	charSize.height = [layoutMgr defaultLineHeightForFont:termFont];

Note that if the Font Size is 17 or greater, the fractional floating advance seems to be used. Go Figure!

Dale Miller
email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Calculating the size of NSFont...
      • From: Aki Inoue <email@hidden>
  • Prev by Date: Re: rotating an object around the center of a view
  • Next by Date: Re: Calculating the size of NSFont...
  • Previous by thread: Re: Calculating the size of NSFont...
  • Next by thread: Re: Calculating the size of NSFont...
  • Index(es):
    • Date
    • Thread