public void Shape() { Buffer.AddUtf("The quick brown espan\u0303ol fox jumps over the lazy dog."); Buffer.GuessSegmentProperties(); var glyphInfoBeforeShaping = Buffer.GlyphInfos.ToArray(); var glyphPositionsBeforeShaping = Buffer.GlyphPositions.ToArray(); TestContext.WriteLine("===== Before Shaping ====="); TestContext.WriteLine("## GlyphInfos:\n" + string.Join(",\n", glyphInfoBeforeShaping .Select(x => $"[{x.Codepoint.AsUnicodeCodepoint()}|{x.GetGlyphFlags()}|{x.Cluster}]"))); TestContext.WriteLine("## GlyphPositions:\n" + string.Join(",\n", glyphPositionsBeforeShaping .Select(x => $"[{x.XAdvance}|{x.YAdvance}|{x.XOffset}|{x.YOffset}]"))); TestContext.WriteLine(); Buffer.Shape(Font); var glyphInfoAfterShaping = Buffer.GlyphInfos.ToArray(); var glyphPositionsAfterShaping = Buffer.GlyphPositions.ToArray(); TestContext.WriteLine("===== After Shaping ====="); TestContext.WriteLine("## GlyphInfos:\n" + string.Join(",\n", glyphInfoAfterShaping .Select(x => $"[{x.Codepoint}|{x.GetGlyphFlags()}|{x.Cluster}]"))); TestContext.WriteLine("## GlyphPositions:\n" + string.Join(",\n", glyphPositionsAfterShaping .Select(x => $"[{x.XAdvance}|{x.YAdvance}|{x.XOffset}|{x.YOffset}]"))); Assert.That(glyphInfoBeforeShaping, Is.Not.EquivalentTo(glyphInfoAfterShaping)); Assert.That(glyphPositionsBeforeShaping, Is.Not.EquivalentTo(glyphPositionsAfterShaping)); }
public void GlyphPositions() { var unused = Buffer.GlyphPositions; Buffer.AddUtf("ab"); // ReSharper disable once RedundantAssignment unused = Buffer.GlyphPositions; }
public void Append() { using (var buffer = new Buffer()) using (var buffer2 = new Buffer()) { buffer2.AddUtf("ab"); Buffer.Append(buffer); Buffer.Append(buffer2); } }
public void AddUtf() { Buffer.AddUtf(new[] { 1u }); Buffer.AddUtf(new[] { 1u, 'a' }); Buffer.AddUtf(new[] { 1u, 'a', 'b' }, 1, 1); Buffer.AddUtf(new ushort[] { 1 }); Buffer.AddUtf(new ushort[] { 1, 'a' }); Buffer.AddUtf(new ushort[] { 1, 'a', 'b' }, 1, 1); Buffer.AddUtf(new byte[] { 1 }); Buffer.AddUtf(new byte[] { 1, (byte)'a' }); Buffer.AddUtf(new byte[] { 1, (byte)'a', (byte)'b' }, 1, 1); Buffer.AddUtf("\n"); Buffer.AddUtf("\na"); Buffer.AddUtf("\nab", 1, 1); }
public void SerializeAndDeserialize() { using (var freetype = new Library()) using (var fira = new Face(freetype, Utilities.GetResource(@"FiraSans-Regular.ttf"))) using (var font = fira.ToHarfBuzzFont()) using (var deserialized = new Buffer()) { Buffer.AddUtf("The quick brown The quick brown espan\u0303ol fox jumps over the lazy dog."); Buffer.Shape(font); var serialized = Buffer.Serialize(0, Buffer.Length, 2048, SerializeFormat.Text); TestContext.WriteLine("Serialized: " + serialized); TestContext.WriteLine(); deserialized.Deserialize(serialized, SerializeFormat.Text); var reserialized = deserialized.Serialize(0, deserialized.Length, 2048, SerializeFormat.Text); TestContext.WriteLine("Reserialized: " + reserialized); Assert.That(reserialized, Is.EqualTo(serialized)); } }
public void Length() { Buffer.AddUtf("ab"); Assert.That(Buffer.Length, Is.EqualTo(2)); }
public void Reverse() { Buffer.Reverse(); Buffer.AddUtf("ab"); Buffer.Reverse(0, 1); }
public void Reset() { Buffer.Reset(); Buffer.AddUtf("ab"); Buffer.Reset(); }
public void GuessSegmentProperties() { Buffer.GuessSegmentProperties(); Buffer.AddUtf("ab"); Buffer.GuessSegmentProperties(); }
public void ClearContents() { Buffer.ClearContents(); Buffer.AddUtf("ab"); Buffer.ClearContents(); }
public void ReverseClusters() { Buffer.ReverseClusters(); Buffer.AddUtf("ab"); Buffer.ReverseClusters(); }