示例#1
0
        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));
        }
示例#2
0
        public void GlyphPositions()
        {
            var unused = Buffer.GlyphPositions;

            Buffer.AddUtf("ab");
            // ReSharper disable once RedundantAssignment
            unused = Buffer.GlyphPositions;
        }
示例#3
0
 public void Append()
 {
     using (var buffer = new Buffer())
         using (var buffer2 = new Buffer())
         {
             buffer2.AddUtf("ab");
             Buffer.Append(buffer);
             Buffer.Append(buffer2);
         }
 }
示例#4
0
 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);
 }
示例#5
0
        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));
                        }
        }
示例#6
0
 public void Length()
 {
     Buffer.AddUtf("ab");
     Assert.That(Buffer.Length, Is.EqualTo(2));
 }
示例#7
0
 public void Reverse()
 {
     Buffer.Reverse();
     Buffer.AddUtf("ab");
     Buffer.Reverse(0, 1);
 }
示例#8
0
 public void Reset()
 {
     Buffer.Reset();
     Buffer.AddUtf("ab");
     Buffer.Reset();
 }
示例#9
0
 public void GuessSegmentProperties()
 {
     Buffer.GuessSegmentProperties();
     Buffer.AddUtf("ab");
     Buffer.GuessSegmentProperties();
 }
示例#10
0
 public void ClearContents()
 {
     Buffer.ClearContents();
     Buffer.AddUtf("ab");
     Buffer.ClearContents();
 }
示例#11
0
 public void ReverseClusters()
 {
     Buffer.ReverseClusters();
     Buffer.AddUtf("ab");
     Buffer.ReverseClusters();
 }