From fd1138fa8ee148dcb619f45b366ab8a928175df3 Mon Sep 17 00:00:00 2001 From: kerams Date: Tue, 10 Feb 2026 11:24:10 +0100 Subject: [PATCH] Use epsilon-aware greater than in TextLine and TextFormatter (#20650) Co-authored-by: Julien Lebosquain --- src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs | 4 ++-- src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs b/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs index 0e9308b6ed..edd73b1405 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs @@ -1,4 +1,4 @@ -// ReSharper disable ForCanBeConvertedToForeach +// ReSharper disable ForCanBeConvertedToForeach using System; using System.Buffers; using System.Collections.Generic; @@ -658,7 +658,7 @@ namespace Avalonia.Media.TextFormatting clusterLength = shapedTextCharacters.GlyphRun.Metrics.FirstCluster + currentRun.Length - currentInfo.GlyphCluster; } - if (currentWidth + clusterWidth > paragraphWidth) + if (MathUtilities.GreaterThan(currentWidth + clusterWidth, paragraphWidth)) { if (runLength == 0 && measuredLength == 0) { diff --git a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs index 417dfc77fa..12ae974c26 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using Avalonia.Media.TextFormatting.Unicode; @@ -1423,7 +1423,7 @@ namespace Avalonia.Media.TextFormatting var overhangLeading = inkBounds.Left; //The width of overhanging pixels at the end of the natural bounds. Positive value means we are inside. var overhangTrailing = widthIncludingWhitespace - inkBounds.Right; - var hasOverflowed = width > _paragraphWidth; + var hasOverflowed = MathUtilities.GreaterThan(width, _paragraphWidth); var start = GetParagraphOffsetX(width, widthIncludingWhitespace);