Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Calculating the size of NSFont...



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.