Esempio n. 1
0
        public void CompileTransformation_MultipleSubstitution_CallsBuilderCorrectly()
        {
            /**
             * Following replacements are used in this test:
             * 1 -> 3 4 5
             * 2 -> 6 7 8
             */
            var table = new MultipleSubstitutionTable
            {
                Coverage = new ListCoverageTable
                {
                    CoveredGlyphIdList = new ushort[] { 1, 2 }
                },
                ReplacementSequences = new[]
                {
                    new ushort[] { 3, 4, 5 },
                    new ushort[] { 6, 7, 8 }
                },
                LookupFlags = LookupFlags.IgnoreLigatures
            };

            var expected = new[]
            {
                (IEnumerable <ITransition>) new[]
                {
                    new SimpleTransition {
                        GlyphId     = 1,
                        HeadShift   = 1,
                        LookupFlags = LookupFlags.IgnoreLigatures,
                        Action      = new SubstitutionAction
                        {
                            ReplacedGlyphCount  = 1,
                            ReplacementGlyphIds = new ushort[] { 3, 4, 5 },
                        }
                    }
                },
                new[]
                {
                    new SimpleTransition {
                        GlyphId     = 2,
                        HeadShift   = 1,
                        LookupFlags = LookupFlags.IgnoreLigatures,
                        Action      = new SubstitutionAction
                        {
                            ReplacedGlyphCount  = 1,
                            ReplacementGlyphIds = new ushort[] { 6, 7, 8 },
                        }
                    }
                }
            };

            this.TestCompileTransformation(table, expected);
        }
        public void GetGeneratedGlyphIds_StateMachone_GeneratesCorrectCollection()
        {
            var table = new MultipleSubstitutionTable
            {
                Coverage = new ListCoverageTable
                {
                    CoveredGlyphIdList = new ushort[] { 1, 2 }
                },
                ReplacementSequences = new[]
                {
                    new ushort[] { 3, 1, 2 },
                    new ushort[] { 4, 3, 2 }
                }
            };

            var compiler = new SubstitutionCompiler();
            var machine  = compiler.Compile(new[] { table });

            Assert.That(machine.GetGeneratedGlyphIds(), Is.EquivalentTo(new ushort[] { 1, 2, 3, 4 }));
        }