Browse Source

Properly handle overhang with RTL FlowDirection (#13631)

Benedikt Stebner 1 year ago
parent
commit
520d9d631a

+ 5 - 4
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,

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