From 9cdca2ada65b245fafd33c9ca7ed46c03c39db8e Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 18 Jul 2023 10:14:09 +0400 Subject: [PATCH] Fix text overflow --- submodules/Display/Source/TextNode.swift | 29 ++++-------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index a4a58949d4..0d4f74c74e 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -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 { - coreTextLine = originalLine + 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