Browse Source

Use epsilon-aware greater than in TextLine and TextFormatter (#20650)

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
release/latest
kerams 1 month ago
committed by Julien Lebosquain
parent
commit
fd1138fa8e
No known key found for this signature in database GPG Key ID: 1833CAD10ACC46FD
  1. 4
      src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs
  2. 4
      src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs

4
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)
{

4
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);

Loading…
Cancel
Save