Re: How to obtain paths of laid-out text
Re: How to obtain paths of laid-out text
- Subject: Re: How to obtain paths of laid-out text
- From: Graham Cox <email@hidden>
- Date: Tue, 11 Nov 2014 18:20:04 +1100
Anyone? Surely there's a supported way to do this? Sample code?
--Graham
> On 8 Nov 2014, at 9:40 am, Graham Cox <email@hidden> wrote:
>
> In the past, I've obtained bezier paths from laid out text using a subclass of NSLayoutManager that overrode the deprecated -showPackedGlyphs:length:... method. This method had a nice smooth impedance match with [NSBezierPath appendPackedGlyphs:]. The method has been deprecated since 10.7, but was still working fine in 10.9. In 10.10, this approach broke. The method is still called, but the resulting glyph runs include all sorts of extraneous characters which seem to be relics of earlier layouts (possibly NSLayoutManager does more aggressive caching in 10.10).
>
> I'm wondering what the modern replacement for doing this is. There's a new method in NSLayoutManager, -showCGGlyphs:positions:count:... which seems to be the modern override point, but it no longer has a smooth match to the NSBezierPath methods that accept glyphs. For one thing, it supplies CGGlyph values, not NSGlyph values, and I can't determine from documentation whether these two are really the same thing, or whether a conversion is required (and if so how to do it). But trying to use the NSBezierPath method -appendGlyphs:count:inFont: by simply casting CGGlyph to NSGlyph doesn't produce the right outcome either - I'm still getting extraneous characters as well as some within the expected laid-out text that just seem random. The effect is worse than before.
>
> What's the modern supported way to do this?
>
> --Graham
>
>
>
> _______________________________________________
>
> 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