Fix text overflow

This commit is contained in:
Ali 2023-07-18 10:14:09 +04:00
parent ac22c025e1
commit 9cdca2ada6

View File

@ -1262,32 +1262,13 @@ open class TextNode: ASDisplayNode {
if lineRange.length == 0 || (CTLineGetTypographicBounds(originalLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(originalLine) + truncationTokenWidth) < Double(lineConstrainedSize.width) {
if didClipLinebreak {
if lineRange.length == 0 {
coreTextLine = CTLineCreateWithAttributedString(NSAttributedString())
} else {
coreTextLine = originalLine
}
additionalTrailingLine = (truncationToken, truncationTokenWidth)
/*let mergedLine = NSMutableAttributedString()
mergedLine.append(attributedString.attributedSubstring(from: NSRange(location: lineRange.location, length: lineRange.length)))
mergedLine.append(truncatedTokenString)
coreTextLine = CTLineCreateWithAttributedString(mergedLine)
let runs = (CTLineGetGlyphRuns(coreTextLine) as [AnyObject]) as! [CTRun]
for run in runs {
let runAttributes: NSDictionary = CTRunGetAttributes(run)
if let _ = runAttributes["CTForegroundColorFromContext"] {
brokenLineRange.length = CTRunGetStringRange(run).location - brokenLineRange.location
break
}
}
if brokenLineRange.location + brokenLineRange.length > lineRange.location + lineRange.length {
brokenLineRange.location = lineRange.location
brokenLineRange.length = lineRange.length
}
if brokenLineRange.location + brokenLineRange.length > attributedString.length {
brokenLineRange.length = attributedString.length - brokenLineRange.location
}
effectiveLineRange = brokenLineRange*/
truncated = true
} else {
coreTextLine = originalLine