зеркало из https://github.com/AvaloniaUI/Avalonia.git
Convert control codepoints into zero width space during shaping (#17004)
This commit is contained in:
Родитель
d5f0188ccf
Коммит
2e83ac1a04
|
@ -14,7 +14,10 @@ namespace Avalonia.Skia
|
|||
{
|
||||
internal class TextShaperImpl : ITextShaperImpl
|
||||
{
|
||||
private const uint ZeroWidthSpace = '\u200b';
|
||||
|
||||
private static readonly ConcurrentDictionary<int, Language> s_cachedLanguage = new();
|
||||
|
||||
public ShapedBuffer ShapeText(ReadOnlyMemory<char> text, TextShaperOptions options)
|
||||
{
|
||||
var textSpan = text.Span;
|
||||
|
@ -68,6 +71,16 @@ namespace Avalonia.Skia
|
|||
|
||||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче