Re: advancementForGlyph problem
Re: advancementForGlyph problem
- Subject: Re: advancementForGlyph problem
- From: Dale Miller <email@hidden>
- Date: Fri, 30 Apr 2010 09:37:08 -0700
For character measurements, if you are using the Cocoa text system,
use the font returned by the NSLayoutManager method
"subtituteFontForFont:" in order to get the screen font used by Cocoa
text. However, experimentally, I found that for font sizes greater
than 17, non-integral values are still returned. I've not found any
documentation as to how Cocoa text (or Quartz text or CoreText) arrive
at the values they actually use.
If you're not using Cocoa text, you will have to do some rounding to
integral values: e.g. floor(value+0.5) or truncating: floor(value).
Experimentally, Cocoa text seems to use rounding for advancement, and
truncation for line height, at least with the fonts/sizes I've tried.
The Application Services Framework provides a couple of functions for
drawing glyphs that give you explicit control over advancement:
CGContextShowGlyphsWithAdvancements
and CGContextShowGlyphsAtLocations.
Dale Miller
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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