> 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, jonat...@mugginsoft.com wrote: > On 24 Sep 2012, at 19:19, Aki Inoue <a...@apple.com> 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 (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/aki%40apple.com > > This email sent to a...@apple.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