• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to obtain paths of laid-out text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to obtain paths of laid-out text


  • Subject: How to obtain paths of laid-out text
  • From: Graham Cox <email@hidden>
  • Date: Sat, 08 Nov 2014 09:40:52 +1100

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


  • Follow-Ups:
    • Re: How to obtain paths of laid-out text
      • From: Kyle Sluder <email@hidden>
    • Re: How to obtain paths of laid-out text
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Weird crash in -[NSSearchField setRecentSearches:]
  • Next by Date: Re: auto layout exception: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
  • Previous by thread: Re: Saving a Document style app
  • Next by thread: Re: How to obtain paths of laid-out text
  • Index(es):
    • Date
    • Thread