• 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
Re: Get text with hyphenation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get text with hyphenation


  • Subject: Re: Get text with hyphenation
  • From: Martin Wierschin <email@hidden>
  • Date: Thu, 09 Oct 2014 17:12:35 -0700

Hello Leonardo,

You are correct that your dirty workaround is not very good, since it won't handle many cases. Since the typesetter inserts a hyphen glyph into the glyph stream whenever hyphenation occurs, perhaps you should check for the presence of that glyph at the end of each line fragment using -[NSLayoutManager glyphAtIndex:].

Another potential approach: you might subclass the typesetter and override -[NSTypesetter shouldBreakLineByHyphenatingBeforeCharacterAtIndex:] and record the instances where super returns YES.

I hope that helps,
~Martin Wierschin


> It works, but "textLine" doens't contain the hyphenation dash, if visible in
> the textView. For example, if the text line ends with "last word of the li-"
> I just get "last word of the li".
>
> I have found a dirty workaround
>
>    if(lineGlyphRange.length > lineTextRange.length)
>    {
>        // I manually add a dash "-" at the end of the textLine extracted.
>    }
>
> but I guess it will not work in many other cases, e.g. when the glyphs are
> more than the chars because of some umlaut...
> How to get that dash, if any? Thank you.
>
>
> Regards
> -- Leonardo

_______________________________________________

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: Get text with hyphenation
      • From: Martin Wierschin <email@hidden>
References: 
 >Get text with hyphenation (From: Leonardo <email@hidden>)

  • Prev by Date: What is fittingSizeHTarget?
  • Next by Date: Re: Get text with hyphenation
  • Previous by thread: Get text with hyphenation
  • Next by thread: Re: Get text with hyphenation
  • Index(es):
    • Date
    • Thread