Browse Source

Merge pull request #4834 from Gillibald/fixes/RightToLeftTextRendering

Make sure we don't crash when RTL text is wrapped
pull/4852/head
Benedikt Stebner 6 years ago
committed by GitHub
parent
commit
06777e0312
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/Avalonia.Visuals/Media/TextFormatting/TextFormatterImpl.cs
  2. 3
      src/Skia/Avalonia.Skia/TextShaperImpl.cs

10
src/Avalonia.Visuals/Media/TextFormatting/TextFormatterImpl.cs

@ -126,7 +126,15 @@ namespace Avalonia.Media.TextFormatting
var lastCluster = glyphRun.GlyphClusters[glyphCount]; var lastCluster = glyphRun.GlyphClusters[glyphCount];
count = lastCluster - firstCluster; if (glyphRun.IsLeftToRight)
{
count = lastCluster - firstCluster;
}
else
{
count = firstCluster - lastCluster;
}
return count > 0; return count > 0;
} }

3
src/Skia/Avalonia.Skia/TextShaperImpl.cs

@ -64,7 +64,8 @@ namespace Avalonia.Skia
new ReadOnlySlice<double>(glyphAdvances), new ReadOnlySlice<double>(glyphAdvances),
new ReadOnlySlice<Vector>(glyphOffsets), new ReadOnlySlice<Vector>(glyphOffsets),
text, text,
new ReadOnlySlice<ushort>(clusters)); new ReadOnlySlice<ushort>(clusters),
buffer.Direction == Direction.LeftToRight ? 0 : 1);
} }
} }

Loading…
Cancel
Save