Browse Source
If the enforced lineheight is less than the regular line height adjust the ascent so the text is properly centered (#14669)
pull/14470/head
Benedikt Stebner
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
7 additions and
0 deletions
-
src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
|
|
@ -1336,6 +1336,13 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
|
if (!double.IsNaN(lineHeight) && !MathUtilities.IsZero(lineHeight)) |
|
|
if (!double.IsNaN(lineHeight) && !MathUtilities.IsZero(lineHeight)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (lineHeight < height) |
|
|
|
|
|
{ |
|
|
|
|
|
var offset = Math.Max(0, height - lineHeight) / 2; |
|
|
|
|
|
|
|
|
|
|
|
ascent += offset; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
height = lineHeight; |
|
|
height = lineHeight; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|