Re: drawGlyphsForGlyphRange layout issue
Re: drawGlyphsForGlyphRange layout issue
- Subject: Re: drawGlyphsForGlyphRange layout issue
- From: Aki Inoue <email@hidden>
- Date: Tue, 25 Sep 2012 18:08:18 -0700
> 1. Why is -drawWithRect:options:attributes: more compatible with NSLayoutManager?
It's not about either is compatible. When using line fragment origin layout, we're using typesetter behavior 10.2 compatibility for historical reasons. NSLayoutManager, by default, uses the latest behavior. That difference causes baseline position differences depending on selected fonts.
By explicitly specifying the baseline origin via -drawWithRect:options:attributes:, you're preventing the typesetter behavior difference to affect the layout.
> 2. I thought the core text route would be more efficient. I have cached my CTLineRefs. Doesn't -drawWithRect:options:attributes: require instantiating an NSLayoutManager on each call?
We don't instantiate NSLayoutManager on each call. In some cases, caching CTLine could be more efficient. In other cases, using NSStringDrawing methods are more efficient.
You should sample with your particular app before making the decision.
Aki
On 2012/09/24, at 12:01, email@hidden wrote:
> On 24 Sep 2012, at 19:19, Aki Inoue <email@hidden> wrote:
>
>> To be compatible with NSLayoutManager, you should use -drawWithRect:options:attributes: here instead of using CT.
> Using -drawWithRect:options:attributes: works.
> 2 questions:
>
> 1. Why is -drawWithRect:options:attributes: more compatible with NSLayoutManager?
> 2. I thought the core text route would be more efficient. I have cached my CTLineRefs. Doesn't -drawWithRect:options:attributes: require instantiating an NSLayoutManager on each call?
>
>>
>> Your source of trouble is using -drawAtPoint: which uses NSStringDrawingUsesLineFragmentOrigin option (layout glyphs from the top instead of the glyph origin).
>>
> Why does the vertical offset only appear for some fonts, not others?
>
> Regards
>
> Jonathan Mitchell
> Mugginsoft LLP
>
>
> _______________________________________________
>
> 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
_______________________________________________
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