public void ShouldAddUtfBySpan() { using (var buffer = new Buffer()) { var bytes = Encoding.UTF8.GetBytes("A").AsSpan(); buffer.AddUtf8(bytes); Assert.Equal(1, buffer.Length); var utf16 = "B".AsSpan(); buffer.AddUtf16(utf16); Assert.Equal(2, buffer.Length); bytes = Encoding.UTF32.GetBytes("C"); var utf32 = new int[] { bytes[0] }; buffer.AddUtf32(utf32); Assert.Equal(3, buffer.Length); } }
public void ShouldNormalize() { using (var buffer = new Buffer()) { buffer.AddUtf16("Â̶"); Font.Shape(buffer); buffer.NormalizeGlyphs(); Assert.Equal(1027, buffer.GlyphPositions[1].YOffset); } }
public void ShouldSerializeGlyphs() { using (var buffer = new Buffer()) { buffer.AddUtf16(SimpleText); buffer.GuessSegmentProperties(); Font.Shape(buffer); var serializedGlyphs = buffer.SerializeGlyphs(); Assert.Equal(SerializedSimpleText, serializedGlyphs); } }
public void ShouldAddUtfByString() { using (var buffer = new Buffer()) { buffer.AddUtf8("A"); Assert.Equal(1, buffer.Length); buffer.AddUtf16("B"); Assert.Equal(2, buffer.Length); buffer.AddUtf32("C"); Assert.Equal(3, buffer.Length); } }
public void ShouldNormalize() { using (var buffer = new Buffer()) { buffer.Direction = Direction.LeftToRight; buffer.AddUtf16("Â̶"); Font.Shape(buffer); buffer.NormalizeGlyphs(); Assert.Equal(0, buffer.GlyphPositions[0].XOffset); Assert.Equal(0, buffer.GlyphPositions[0].YOffset); Assert.Equal(-1135, buffer.GlyphPositions[1].XOffset); Assert.Equal(0, buffer.GlyphPositions[1].YOffset); } }
public void ShouldAddUtfBySpan() { using (var buffer = new Buffer()) { var utf8 = Encoding.UTF8.GetBytes("A").AsSpan(); buffer.AddUtf8(utf8); Assert.Equal(1, buffer.Length); var utf16 = "B".AsSpan(); buffer.AddUtf16(utf16); Assert.Equal(2, buffer.Length); var utf32 = new[] { char.ConvertToUtf32("C", 0) }; buffer.AddUtf32(utf32); Assert.Equal(3, buffer.Length); } }