diff --git a/src/Skia/Avalonia.Skia/TextShaperImpl.cs b/src/Skia/Avalonia.Skia/TextShaperImpl.cs index 963edd604f4..768e8f3a2f3 100644 --- a/src/Skia/Avalonia.Skia/TextShaperImpl.cs +++ b/src/Skia/Avalonia.Skia/TextShaperImpl.cs @@ -14,7 +14,10 @@ namespace Avalonia.Skia { internal class TextShaperImpl : ITextShaperImpl { + private const uint ZeroWidthSpace = '\u200b'; + private static readonly ConcurrentDictionary s_cachedLanguage = new(); + public ShapedBuffer ShapeText(ReadOnlyMemory text, TextShaperOptions options) { var textSpan = text.Span; @@ -68,6 +71,16 @@ public ShapedBuffer ShapeText(ReadOnlyMemory text, TextShaperOptions optio var glyphCluster = (int)(sourceInfo.Cluster); + if (glyphIndex == 0) + { + var codepoint = Codepoint.ReadAt(textSpan, glyphCluster, out _); + + if (codepoint.GeneralCategory == GeneralCategory.Control) + { + glyphIndex = options.Typeface.GetGlyph(ZeroWidthSpace); + } + } + var glyphAdvance = GetGlyphAdvance(glyphPositions, i, textScale) + options.LetterSpacing; var glyphOffset = GetGlyphOffset(glyphPositions, i, textScale);