|
|
@ -82,24 +82,15 @@ namespace Avalonia.Media.TextFormatting |
|
|
var previousGlyphTypeface = previousProperties?.CachedGlyphTypeface; |
|
|
var previousGlyphTypeface = previousProperties?.CachedGlyphTypeface; |
|
|
var textSpan = text.Span; |
|
|
var textSpan = text.Span; |
|
|
|
|
|
|
|
|
if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out var count, out var script)) |
|
|
if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out var count)) |
|
|
{ |
|
|
{ |
|
|
if (script == Script.Common && previousGlyphTypeface is not null) |
|
|
|
|
|
{ |
|
|
|
|
|
if (TryGetShapeableLength(textSpan, previousGlyphTypeface, null, out var fallbackCount, out _)) |
|
|
|
|
|
{ |
|
|
|
|
|
return new UnshapedTextRun(text.Slice(0, fallbackCount), |
|
|
|
|
|
defaultProperties.WithTypeface(previousTypeface!.Value), biDiLevel); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new UnshapedTextRun(text.Slice(0, count), defaultProperties.WithTypeface(defaultTypeface), |
|
|
return new UnshapedTextRun(text.Slice(0, count), defaultProperties.WithTypeface(defaultTypeface), |
|
|
biDiLevel); |
|
|
biDiLevel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (previousGlyphTypeface is not null) |
|
|
if (previousGlyphTypeface is not null) |
|
|
{ |
|
|
{ |
|
|
if (TryGetShapeableLength(textSpan, previousGlyphTypeface, defaultGlyphTypeface, out count, out _)) |
|
|
if (TryGetShapeableLength(textSpan, previousGlyphTypeface, defaultGlyphTypeface, out count)) |
|
|
{ |
|
|
{ |
|
|
return new UnshapedTextRun(text.Slice(0, count), |
|
|
return new UnshapedTextRun(text.Slice(0, count), |
|
|
defaultProperties.WithTypeface(previousTypeface!.Value), biDiLevel); |
|
|
defaultProperties.WithTypeface(previousTypeface!.Value), biDiLevel); |
|
|
@ -130,7 +121,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
|
var fallbackGlyphTypeface = fontManager.GetOrAddGlyphTypeface(fallbackTypeface); |
|
|
var fallbackGlyphTypeface = fontManager.GetOrAddGlyphTypeface(fallbackTypeface); |
|
|
|
|
|
|
|
|
if (matchFound && TryGetShapeableLength(textSpan, fallbackGlyphTypeface, defaultGlyphTypeface, out count, out _)) |
|
|
if (matchFound && TryGetShapeableLength(textSpan, fallbackGlyphTypeface, defaultGlyphTypeface, out count)) |
|
|
{ |
|
|
{ |
|
|
//Fallback found
|
|
|
//Fallback found
|
|
|
return new UnshapedTextRun(text.Slice(0, count), defaultProperties.WithTypeface(fallbackTypeface), |
|
|
return new UnshapedTextRun(text.Slice(0, count), defaultProperties.WithTypeface(fallbackTypeface), |
|
|
@ -160,17 +151,15 @@ namespace Avalonia.Media.TextFormatting |
|
|
/// <param name="glyphTypeface">The typeface that is used to find matching characters.</param>
|
|
|
/// <param name="glyphTypeface">The typeface that is used to find matching characters.</param>
|
|
|
/// <param name="defaultGlyphTypeface">The default typeface.</param>
|
|
|
/// <param name="defaultGlyphTypeface">The default typeface.</param>
|
|
|
/// <param name="length">The shapeable length.</param>
|
|
|
/// <param name="length">The shapeable length.</param>
|
|
|
/// <param name="script"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
internal static bool TryGetShapeableLength( |
|
|
internal static bool TryGetShapeableLength( |
|
|
ReadOnlySpan<char> text, |
|
|
ReadOnlySpan<char> text, |
|
|
IGlyphTypeface glyphTypeface, |
|
|
IGlyphTypeface glyphTypeface, |
|
|
IGlyphTypeface? defaultGlyphTypeface, |
|
|
IGlyphTypeface? defaultGlyphTypeface, |
|
|
out int length, |
|
|
out int length) |
|
|
out Script script) |
|
|
|
|
|
{ |
|
|
{ |
|
|
length = 0; |
|
|
length = 0; |
|
|
script = Script.Unknown; |
|
|
var script = Script.Unknown; |
|
|
|
|
|
|
|
|
if (text.IsEmpty) |
|
|
if (text.IsEmpty) |
|
|
{ |
|
|
{ |
|
|
|