Browse Source

Fix bidi mirror handling

pull/8998/head
Benedikt Stebner 4 years ago
parent
commit
98655d04ce
  1. 2
      src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs
  2. 3
      src/Avalonia.Base/Media/TextFormatting/Unicode/BiDiData.cs
  3. 7
      src/Skia/Avalonia.Skia/TextShaperImpl.cs
  4. 7
      src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs

2
src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs

@ -76,7 +76,7 @@ namespace Avalonia.Media.TextFormatting
{
if (script == Script.Common && previousTypeface is not null)
{
if (TryGetShapeableLength(text, previousTypeface.Value, defaultTypeface, out var fallbackCount, out _))
if (TryGetShapeableLength(text, previousTypeface.Value, null, out var fallbackCount, out _))
{
return new ShapeableTextCharacters(text.Take(fallbackCount),
defaultProperties.WithTypeface(previousTypeface.Value), biDiLevel);

3
src/Avalonia.Base/Media/TextFormatting/Unicode/BiDiData.cs

@ -71,9 +71,6 @@ namespace Avalonia.Media.TextFormatting.Unicode
// Resolve the BidiCharacterType, paired bracket type and paired
// bracket values for all code points
HasBrackets = false;
HasEmbeddings = false;
HasIsolates = false;
int i = Length;

7
src/Skia/Avalonia.Skia/TextShaperImpl.cs

@ -27,7 +27,7 @@ namespace Avalonia.Skia
buffer.GuessSegmentProperties();
buffer.Direction = Direction.LeftToRight; //Always shape LeftToRight
buffer.Direction = (bidiLevel & 1) == 0 ? Direction.LeftToRight : Direction.RightToLeft;
buffer.Language = new Language(culture ?? CultureInfo.CurrentCulture);
@ -35,6 +35,11 @@ namespace Avalonia.Skia
font.Shape(buffer);
if(buffer.Direction == Direction.RightToLeft)
{
buffer.Reverse();
}
font.GetScale(out var scaleX, out _);
var textScale = fontRenderingEmSize / scaleX;

7
src/Windows/Avalonia.Direct2D1/Media/TextShaperImpl.cs

@ -27,7 +27,7 @@ namespace Avalonia.Direct2D1.Media
buffer.GuessSegmentProperties();
buffer.Direction = Direction.LeftToRight; //Always shape LeftToRight
buffer.Direction = (bidiLevel & 1) == 0 ? Direction.LeftToRight : Direction.RightToLeft;
buffer.Language = new Language(culture ?? CultureInfo.CurrentCulture);
@ -35,6 +35,11 @@ namespace Avalonia.Direct2D1.Media
font.Shape(buffer);
if(buffer.Direction == Direction.RightToLeft)
{
buffer.Reverse();
}
font.GetScale(out var scaleX, out _);
var textScale = fontRenderingEmSize / scaleX;

Loading…
Cancel
Save