Browse Source

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

* [macOS] Fix overhand leading calculation

* Adjust TextLineMetrics

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

6
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

After

Width:  |  Height:  |  Size: 529 B

Loading…
Cancel
Save