diff --git a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs index 09042b9d60..b4534fd274 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs @@ -1299,8 +1299,6 @@ namespace Avalonia.Media.TextFormatting } } - var overhangAfter = Math.Max(0, bounds.Bottom - height); - var width = widthIncludingWhitespace; for (var i = _textRuns.Length - 1; i >= 0; i--) @@ -1327,9 +1325,10 @@ namespace Avalonia.Media.TextFormatting } } - var start = GetParagraphOffsetX(width, widthIncludingWhitespace); + //The width of overhanging pixels ath the bottom + var overhangAfter = Math.Max(0, bounds.Bottom - height); //The width of overhanging pixels at the origin - var overhangLeading = Math.Max(0, start - bounds.Left); + var overhangLeading = bounds.Left; //The width of overhanging pixels at the end var overhangTrailing = Math.Max(0, bounds.Width - widthIncludingWhitespace); var hasOverflowed = width > _paragraphWidth; @@ -1339,6 +1338,8 @@ namespace Avalonia.Media.TextFormatting height = lineHeight; } + var start = GetParagraphOffsetX(width, widthIncludingWhitespace); + return new TextLineMetrics { HasOverflowed = hasOverflowed, diff --git a/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png b/tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png index 30e2ca8662..c8320cdb97 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