Browse Source

Properly handle overhang with RTL FlowDirection (#13631)

pull/13644/head
Benedikt Stebner 2 years ago
committed by GitHub
parent
commit
520d9d631a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
  2. BIN
      tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png

9
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; var width = widthIncludingWhitespace;
for (var i = _textRuns.Length - 1; i >= 0; i--) 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 //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 //The width of overhanging pixels at the end
var overhangTrailing = Math.Max(0, bounds.Width - widthIncludingWhitespace); var overhangTrailing = Math.Max(0, bounds.Width - widthIncludingWhitespace);
var hasOverflowed = width > _paragraphWidth; var hasOverflowed = width > _paragraphWidth;
@ -1339,6 +1338,8 @@ namespace Avalonia.Media.TextFormatting
height = lineHeight; height = lineHeight;
} }
var start = GetParagraphOffsetX(width, widthIncludingWhitespace);
return new TextLineMetrics return new TextLineMetrics
{ {
HasOverflowed = hasOverflowed, HasOverflowed = hasOverflowed,

BIN
tests/TestFiles/Skia/Controls/TextBlock/RestrictedHeight_VerticalAlign.expected.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 528 B

Loading…
Cancel
Save