Browse Source

Try to fix line height measurement

pull/7746/head
Benedikt Stebner 5 years ago
parent
commit
0edd67157e
  1. 14
      src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs

14
src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia.Media.TextFormatting.Unicode;
using Avalonia.Utilities; using Avalonia.Utilities;
namespace Avalonia.Media.TextFormatting namespace Avalonia.Media.TextFormatting
@ -1165,9 +1164,9 @@ namespace Avalonia.Media.TextFormatting
} }
} }
if (ascent > -drawableTextRun.Size.Height) if (descent - ascent + lineGap < drawableTextRun.Size.Height || lineHeight < drawableTextRun.Size.Height)
{ {
ascent = -drawableTextRun.Size.Height; lineHeight = drawableTextRun.Size.Height;
} }
break; break;
@ -1178,9 +1177,12 @@ namespace Avalonia.Media.TextFormatting
start = GetParagraphOffsetX(width, widthIncludingWhitespace, _paragraphWidth, start = GetParagraphOffsetX(width, widthIncludingWhitespace, _paragraphWidth,
_paragraphProperties.TextAlignment, _paragraphProperties.FlowDirection); _paragraphProperties.TextAlignment, _paragraphProperties.FlowDirection);
height = double.IsNaN(lineHeight) || MathUtilities.IsZero(lineHeight) ? height = descent - ascent + lineGap;
descent - ascent + lineGap :
lineHeight; if(!double.IsNaN(lineHeight) && lineHeight > height)
{
height = lineHeight;
}
return new TextLineMetrics(widthIncludingWhitespace > _paragraphWidth, height, newLineLength, start, return new TextLineMetrics(widthIncludingWhitespace > _paragraphWidth, height, newLineLength, start,
-ascent, trailingWhitespaceLength, width, widthIncludingWhitespace); -ascent, trailingWhitespaceLength, width, widthIncludingWhitespace);

Loading…
Cancel
Save