Get text with hyphenation
Get text with hyphenation
- Subject: Get text with hyphenation
- From: Leonardo <email@hidden>
- Date: Wed, 08 Oct 2014 22:29:29 +0200
- Thread-topic: Get text with hyphenation
Hi, I have to draw several lines of text, one by one, to an HTML page.
I get the text from an NSTextView, iterating throught the text lines:
lineRect = [layoutManager lineFragmentRectForGlyphAtIndex:index
effectiveRange:&lineGlyphRange];
index = NSMaxRange(lineGlyphRange);
lineTextRange = [layoutManager
characterRangeForGlyphRange:lineGlyphRange
actualGlyphRange:&actualTextRange];
textLine = [self.textStorage attributedSubstringFromRange:lineTextRange]
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