Browse Source

Fix ShapedTextRun Split for sequences that contain invisible character that belong to the same cluster (#13385)

pull/13394/head
Benedikt Stebner 3 years ago
committed by GitHub
parent
commit
2cfdc09886
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs

18
src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs

@ -107,15 +107,29 @@ namespace Avalonia.Media.TextFormatting
for (var i = 0; i < ShapedBuffer.Length; i++)
{
var advance = ShapedBuffer[i].GlyphAdvance;
var currentCluster = ShapedBuffer[i].GlyphCluster;
if (currentWidth + advance > availableWidth)
{
break;
}
Codepoint.ReadAt(charactersSpan, length, out var count);
if(i + 1 < ShapedBuffer.Length)
{
var nextCluster = ShapedBuffer[i + 1].GlyphCluster;
length += count;
var count = nextCluster - currentCluster;
length += count;
}
else
{
Codepoint.ReadAt(charactersSpan, length, out var count);
length += count;
}
currentWidth += advance;
}

Loading…
Cancel
Save