TextNode: Add more checks

This commit is contained in:
Ali 2022-01-22 16:27:25 +04:00
parent 4447916713
commit 3dfa391714

View File

@ -1086,6 +1086,7 @@ public class TextNode: ASDisplayNode {
}
var headIndent: CGFloat = 0.0
if brokenLineRange.location >= 0 && brokenLineRange.length > 0 && brokenLineRange.location + brokenLineRange.length <= attributedString.length {
attributedString.enumerateAttributes(in: NSMakeRange(brokenLineRange.location, brokenLineRange.length), options: []) { attributes, range, _ in
if attributes[NSAttributedString.Key(rawValue: "TelegramSpoiler")] != nil || attributes[NSAttributedString.Key(rawValue: "Attribute__Spoiler")] != nil {
var ascent: CGFloat = 0.0
@ -1126,6 +1127,7 @@ public class TextNode: ASDisplayNode {
}
}
}
let lineWidth = min(lineConstrainedSize.width, ceil(CGFloat(CTLineGetTypographicBounds(coreTextLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(coreTextLine))))
let lineFrame = CGRect(x: lineCutoutOffset + headIndent, y: lineOriginY, width: lineWidth, height: fontLineHeight)