From eb4aee0d8bbd89d794a705d7ec8ac97149f2e7d0 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Wed, 22 Nov 2023 00:29:10 +0100 Subject: [PATCH] [WIP]Fix overhang leading calculation for negative values (#13672) * [macOS] Fix overhand leading calculation * Adjust TextLineMetrics * Update expected result --- .../Media/TextFormatting/TextLineImpl.cs | 6 +++--- .../RestrictedHeight_VerticalAlign.expected.png | Bin 528 -> 529 bytes 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs index b4534fd274..efaab511ce 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs @@ -1325,12 +1325,12 @@ namespace Avalonia.Media.TextFormatting } } - //The width of overhanging pixels ath the bottom + //The width of overhanging pixels at the bottom var overhangAfter = Math.Max(0, bounds.Bottom - height); //The width of overhanging pixels at the origin - var overhangLeading = bounds.Left; + var overhangLeading = Math.Abs(Math.Min(bounds.Left, 0)); //The width of overhanging pixels at the end - var overhangTrailing = Math.Max(0, bounds.Width - widthIncludingWhitespace); + var overhangTrailing = Math.Max(0, bounds.Right - widthIncludingWhitespace); var hasOverflowed = width > _paragraphWidth; if (!double.IsNaN(lineHeight) && !MathUtilities.IsZero(lineHeight)) diff --git a/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png b/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png index c8320cdb97c182922987f97e07a33f1c68eff45e..30e2ca86621188f40d0080454681b72b4fcf83c7 100644 GIT binary patch delta 487 zcmbQhGLdD1N&N{=7srr_IdAV620eBVU^wvb71N>J6ME9`=s&RhE|a?C&!PB2kBXUk z1|n^TGQ#C5Q*+Cw3Ps9!25?AG|JxBp!6nI2R7_|#Qu+w}`2G~;!@n>J2L{_3!= zD0HjU{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