Browse Source

Fix embedded run Baseline handling

pull/7746/head
Benedikt Stebner 5 years ago
parent
commit
301dbf2635
  1. 19
      src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs

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

@ -187,7 +187,7 @@ namespace Avalonia.Media.TextFormatting
} }
default: default:
{ {
if(distance < currentRun.Size.Width / 2) if (distance < currentRun.Size.Width / 2)
{ {
characterHit = new CharacterHit(currentPosition); characterHit = new CharacterHit(currentPosition);
} }
@ -311,12 +311,12 @@ namespace Avalonia.Media.TextFormatting
} }
default: default:
{ {
if(characterIndex == currentPosition) if (characterIndex == currentPosition)
{ {
return currentDistance; return currentDistance;
} }
if(characterIndex == currentPosition + textRun.TextSourceLength) if (characterIndex == currentPosition + textRun.TextSourceLength)
{ {
return currentDistance + textRun.Size.Width; return currentDistance + textRun.Size.Width;
} }
@ -897,7 +897,7 @@ namespace Avalonia.Media.TextFormatting
var previousPosition = foundCharacterHit.FirstCharacterIndex + foundCharacterHit.TrailingLength; var previousPosition = foundCharacterHit.FirstCharacterIndex + foundCharacterHit.TrailingLength;
if(foundCharacterHit.TrailingLength > 0 && previousPosition == characterIndex) if (foundCharacterHit.TrailingLength > 0 && previousPosition == characterIndex)
{ {
previousCharacterHit = new CharacterHit(foundCharacterHit.FirstCharacterIndex); previousCharacterHit = new CharacterHit(foundCharacterHit.FirstCharacterIndex);
} }
@ -911,7 +911,7 @@ namespace Avalonia.Media.TextFormatting
} }
default: default:
{ {
if(characterIndex == currentPosition + currentRun.TextSourceLength) if (characterIndex == currentPosition + currentRun.TextSourceLength)
{ {
previousCharacterHit = new CharacterHit(currentPosition); previousCharacterHit = new CharacterHit(currentPosition);
@ -1072,7 +1072,7 @@ namespace Avalonia.Media.TextFormatting
lineGap = fontMetrics.LineGap; lineGap = fontMetrics.LineGap;
} }
if(descent - ascent + lineGap > height) if (descent - ascent + lineGap > height)
{ {
height = descent - ascent + lineGap; height = descent - ascent + lineGap;
} }
@ -1156,6 +1156,11 @@ namespace Avalonia.Media.TextFormatting
height = drawableTextRun.Size.Height; height = drawableTextRun.Size.Height;
} }
if (ascent > -drawableTextRun.Baseline)
{
ascent = -drawableTextRun.Baseline;
}
break; break;
} }
} }
@ -1164,7 +1169,7 @@ namespace Avalonia.Media.TextFormatting
start = GetParagraphOffsetX(width, widthIncludingWhitespace, _paragraphWidth, start = GetParagraphOffsetX(width, widthIncludingWhitespace, _paragraphWidth,
_paragraphProperties.TextAlignment, _paragraphProperties.FlowDirection); _paragraphProperties.TextAlignment, _paragraphProperties.FlowDirection);
if(!double.IsNaN(lineHeight) && !MathUtilities.IsZero(lineHeight)) if (!double.IsNaN(lineHeight) && !MathUtilities.IsZero(lineHeight))
{ {
height = lineHeight; height = lineHeight;
} }

Loading…
Cancel
Save