iOS CoreText CTLineGetStringRange with CTLineRef from CTLineCreateTruncatedLine
Asked Answered
P

1

2

I have the following code in iOS:

CFAttributedStringRef attributedString = ...
CTLineRef line = CTLineCreateWithAttributedString(attributedString);
CTLineRef truncatedLine = CTLineCreateTruncatedLine(line, 50.0, kCTLineTruncationEnd, NULL);

CFRange lineRange = CTLineGetStringRange(line);
CFRange truncatedLineRange = CTLineGetStringRange(truncatedLine);

My lineRange is the same as truncatedLineRange. Why? The documentation makes no mention of this.

Phenosafranine answered 15/4, 2011 at 3:16 Comment(0)
P
2

According to the coretext-dev mailing list, this is expected behavior:

The truncated string still covers the original string range, it's just that some glyph(s) have subsumed the truncated characters. Besides, it would be impossible to represent a discontiguous string range as a CFRange in the case of middle truncation.

Phenosafranine answered 15/4, 2011 at 5:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.