Browse Source

[WIP]Fix overhang leading calculation for negative values (#13672)

* [macOS] Fix overhand leading calculation

* Adjust TextLineMetrics

* Update expected result
Benedikt Stebner 2 years ago
parent
commit
b94b011c94

+ 3 - 3
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))

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