On Aug 30, 2016, at 8:47 AM, Andreas Falkenhahn <andr...@falkenhahn.com> wrote:
> 
>> That said, when drawing strings, there are the functions
>> CGContextSetShouldSubpixelPositionFonts() and
>> CGContextSetAllowsFontSubpixelPositioning().  Those can be used to
>> turn off sub-pixel positioning of glyphs.  It may be that ATSUI
>> wasn't capable of that and so turning it off gets you the same positioning 
>> as ATSUI.
> 
>> There doesn't seem to be a direct way to ask Core Text for the
>> measurements corresponding to that drawing mode.  So, you may need
>> to ask your CTLine for its CTRuns and then ask the CTRun for the
>> individual glyph advances.
> 
> Hmm, I don't understand. The only CTRun APIs that take a CGContextRef are 
> CTRunGetImageBounds()
> and CTRunDraw(). I'd have to use CTRunGetAdvances(), though, but this 
> function doesn't accept
> a CGContextRef so I don't see how I should implement your suggestions...

I mentioned CGContext only to illustrate the point that there are two 
text-rendering modes, one that allows for sub-pixel glyph position (and thus 
advances) and one which doesn't.  The other part of what I said has nothing to 
do with CGContext.

I would have hoped there would be APIs built into Core Text that would measure 
the text as it would be rendered when sub-pixel glyph positioning isn't 
allowed, but there don't seem to be.  So, I suggested a way to compute it 
manually.  Get the individual glyph advances for the run and combine them, but 
only after applying ceil() or round() to them (I'm not sure which).

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to