Browse Source

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

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
pull/20449/head
kerams 1 month ago
committed by GitHub
parent
commit
cdb91f7f78
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  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;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
@ -662,7 +662,7 @@ namespace Avalonia.Media.TextFormatting
clusterLength = shapedTextCharacters.GlyphRun.Metrics.FirstCluster + currentRun.Length - currentInfo.GlyphCluster; clusterLength = shapedTextCharacters.GlyphRun.Metrics.FirstCluster + currentRun.Length - currentInfo.GlyphCluster;
} }
if (currentWidth + clusterWidth > paragraphWidth) if (MathUtilities.GreaterThan(currentWidth + clusterWidth, paragraphWidth))
{ {
if (runLength == 0 && measuredLength == 0) 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.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Avalonia.Media.TextFormatting.Unicode; using Avalonia.Media.TextFormatting.Unicode;
@ -1423,7 +1423,7 @@ namespace Avalonia.Media.TextFormatting
var overhangLeading = inkBounds.Left; var overhangLeading = inkBounds.Left;
//The width of overhanging pixels at the end of the natural bounds. Positive value means we are inside. //The width of overhanging pixels at the end of the natural bounds. Positive value means we are inside.
var overhangTrailing = widthIncludingWhitespace - inkBounds.Right; var overhangTrailing = widthIncludingWhitespace - inkBounds.Right;
var hasOverflowed = width > _paragraphWidth; var hasOverflowed = MathUtilities.GreaterThan(width, _paragraphWidth);
var start = GetParagraphOffsetX(width, widthIncludingWhitespace); var start = GetParagraphOffsetX(width, widthIncludingWhitespace);

Loading…
Cancel
Save