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 c8320cdb97..30e2ca8662 100644 Binary files a/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png and b/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png differ