开发者

iOS CoreText CTLineGetStringRange with CTLineRef from CTLineCreateTruncatedLine

开发者 https://www.devze.com 2023-02-25 04:17 出处:网络
I have the following code in iOS: CFAttributedStringRef attributedString = ... CTLineRef line = CTLineCreateWithAttributedString(attributedString);

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 = CTLineGetStringRan开发者_高级运维ge(truncatedLine);

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消