Пример #1
0
        public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany03()
        {
            byte[] ttf = StreamUtil.InputStreamToArray(new FileStream(iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
                                                                                                                    .CurrentContext.TestDirectory) + "/resources/itext/io/font/otf/FreeSans.ttf", FileMode.Open, FileAccess.Read
                                                                      ));
            TrueTypeFont font = new TrueTypeFont(ttf);
            // no actual text is set
            GlyphLine line = new GlyphLine(ConstructGlyphListFromString("A", font));

            line.SubstituteOneToMany(font.GetGsubTable(), new int[] { 39, 40 });
            NUnit.Framework.Assert.IsNull(line.actualText);
        }
Пример #2
0
        public virtual void TestFetchLangSysByTag()
        {
            TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.CreateFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"
                                                                                   );
            GlyphSubstitutionTableReader gsub = fontProgram.GetGsubTable();
            ScriptRecord mym2 = gsub.GetScriptRecords()[0];

            NUnit.Framework.Assert.AreEqual("mym2", mym2.tag);
            // default LangSys has no tag
            NUnit.Framework.Assert.AreEqual("", gsub.GetLanguageRecord("mym2").tag);
            NUnit.Framework.Assert.AreEqual(LanguageTags.SGAW_KAREN, gsub.GetLanguageRecord("mym2", LanguageTags.SGAW_KAREN
                                                                                            ).tag);
            NUnit.Framework.Assert.AreEqual(LanguageTags.MON, gsub.GetLanguageRecord("mym2", LanguageTags.MON).tag);
            NUnit.Framework.Assert.IsNull(gsub.GetLanguageRecord(null));
            NUnit.Framework.Assert.IsNull(gsub.GetLanguageRecord("mym3"));
            NUnit.Framework.Assert.IsNull(gsub.GetLanguageRecord("mym3", LanguageTags.SGAW_KAREN));
        }
Пример #3
0
        public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany02()
        {
            String expectedActualTextForFirstGlyph = "A";

            byte[] ttf = StreamUtil.InputStreamToArray(new FileStream(iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
                                                                                                                    .CurrentContext.TestDirectory) + "/resources/itext/io/font/otf/FreeSans.ttf", FileMode.Open, FileAccess.Read
                                                                      ));
            TrueTypeFont font = new TrueTypeFont(ttf);
            GlyphLine    line = new GlyphLine(ConstructGlyphListFromString("A", font));

            line.SetActualText(0, 1, expectedActualTextForFirstGlyph);
            line.SubstituteOneToMany(font.GetGsubTable(), new int[] { 39, 40 });
            NUnit.Framework.Assert.IsNotNull(line.actualText);
            NUnit.Framework.Assert.AreEqual(2, line.actualText.Count);
            NUnit.Framework.Assert.AreSame(line.actualText[0], line.actualText[1]);
            NUnit.Framework.Assert.AreEqual(expectedActualTextForFirstGlyph, line.actualText[0].value);
        }
Пример #4
0
        public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany01()
        {
            String expectedActualTextForFirstGlyph  = "0";
            String expectedActualTextForSecondGlyph = "A";

            byte[] ttf = StreamUtil.InputStreamToArray(new FileStream(iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
                                                                                                                    .CurrentContext.TestDirectory) + "/resources/itext/io/font/otf/FreeSans.ttf", FileMode.Open, FileAccess.Read
                                                                      ));
            TrueTypeFont font = new TrueTypeFont(ttf);
            // no actual text for the second glyph is set - it should be created during substitution
            GlyphLine line = new GlyphLine(ConstructGlyphListFromString("AA", font));

            line.SetActualText(0, 1, expectedActualTextForFirstGlyph);
            line.idx = 1;
            line.SubstituteOneToMany(font.GetGsubTable(), new int[] { 39, 40 });
            NUnit.Framework.Assert.IsNotNull(line.actualText);
            NUnit.Framework.Assert.AreEqual(3, line.actualText.Count);
            NUnit.Framework.Assert.AreSame(line.actualText[1], line.actualText[2]);
            NUnit.Framework.Assert.AreEqual(expectedActualTextForSecondGlyph, line.actualText[1].value);
            // check that it hasn't been corrupted
            NUnit.Framework.Assert.AreEqual(expectedActualTextForFirstGlyph, line.actualText[0].value);
        }