A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
1.1 KiB

using Avalonia.Media.TextFormatting;
using Avalonia.Media.TextFormatting.Unicode;
using Avalonia.Platform;
namespace Avalonia.UnitTests
{
public class MockTextShaperImpl : ITextShaperImpl
{
public ShapedBuffer ShapeText(CharacterBufferReference text, int length, TextShaperOptions options)
{
var typeface = options.Typeface;
var fontRenderingEmSize = options.FontRenderingEmSize;
var bidiLevel = options.BidiLevel;
var characterBufferRange = new CharacterBufferRange(text, length);
var shapedBuffer = new ShapedBuffer(characterBufferRange, length, typeface, fontRenderingEmSize, bidiLevel);
for (var i = 0; i < shapedBuffer.Length;)
{
var glyphCluster = i + text.OffsetToFirstChar;
var codepoint = Codepoint.ReadAt(characterBufferRange, i, out var count);
var glyphIndex = typeface.GetGlyph(codepoint);
shapedBuffer[i] = new GlyphInfo(glyphIndex, glyphCluster, 10);
i += count;
}
return shapedBuffer;
}
}
}