On 29.08.2016 at 17:46 Ken Thomases wrote:

> On Aug 29, 2016, at 9:55 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:

>> I'm migrating some code from ATSUI to Core Text. It's pretty raw stuff, i.e. 
>> it does
>> all the layouting itself and only uses ATSUI/Core Text to draw single lines 
>> of text to
>> raw pixel buffers and obtain measurements.

>> The raw pixel data emitted by ATSUDrawText() and CTLineDraw() seems to match 
>> exactly.
>> Also, the measurements returned by ATSUI/Core Text seem to match most of the 
>> time. Thus,
>> it's usually the case that the pixels in text generated using ATSUI match 
>> exactly the
>> text pixels generated by Core Text. 

>> That's nice to see and I didn't expect that but it activated a perfectionist 
>> tendency
>> in me so that I ran some hardcore tests with lots of different texts printed 
>> in different
>> sizes and layouts to see if I could find a deviation between ATSUI and Core 
>> Text. And I
>> did ;) It happens only in very rare cases but sometimes the cursor advance 
>> returned by
>> ATSUI is a pixel off from the cursor advance returned by Core Text. But only 
>> very
>> seldomly. However, in complex layouts this can then accumulate and lead to 
>> an entirely
>> different layout if wordwrapping is involved.

> First, this has nothing to do with Cocoa and so isn't appropriate for 
> Cocoa-Dev.

Oops, sorry, I didn't know that there was a separate mailing list for Core 
Text. I'll
ask again over there if we don't manage to solve it here.

> 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...

-- 
Best regards,
 Andreas Falkenhahn                            mailto:andr...@falkenhahn.com

_______________________________________________

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