public virtual void GetAscentOfTextWithGlyphWithoutBBoxTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); font.SetFontProgram(new PdfFontUnitTest.TestFontProgram()); char[] text = new char[] { (char)PdfFontUnitTest.TestFont.SIMPLE_GLYPH, (char)PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WITHOUT_BBOX }; String textAsString = new String(text); int expectedMaxAscent = Math.Max(font.GetGlyph(PdfFontUnitTest.TestFont.SIMPLE_GLYPH).GetBbox()[3], FONT_METRICS_ASCENT ); int expectedValue = (int)(expectedMaxAscent * FONT_SIZE / (double)FontProgram.UNITS_NORMALIZATION); NUnit.Framework.Assert.AreEqual(expectedValue, font.GetAscent(textAsString, FONT_SIZE)); }
public virtual void GetAscentOfTextTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] text = new char[] { (char)PdfFontUnitTest.TestFont.SIMPLE_GLYPH, PdfFontUnitTest.TestFont.COMPLEX_GLYPH_AS_CHARS [0], PdfFontUnitTest.TestFont.COMPLEX_GLYPH_AS_CHARS[1] }; String textAsString = new String(text); int expectedMaxAscent = Math.Max(font.GetGlyph(PdfFontUnitTest.TestFont.SIMPLE_GLYPH).GetBbox()[3], font.GetGlyph (PdfFontUnitTest.TestFont.COMPLEX_GLYPH).GetBbox()[3]); int expectedValue = (int)(expectedMaxAscent * FONT_SIZE / (double)FontProgram.UNITS_NORMALIZATION); NUnit.Framework.Assert.AreEqual(expectedValue, font.GetAscent(textAsString, FONT_SIZE)); }
public virtual void MakeObjectIndirectWhileFontIsIndirectTest() { using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) { // to avoid an exception document.AddNewPage(); PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); font.GetPdfObject().MakeIndirect(document); PdfDictionary dictionary = new PdfDictionary(); NUnit.Framework.Assert.IsTrue(font.MakeObjectIndirect(dictionary)); NUnit.Framework.Assert.IsNotNull(dictionary.GetIndirectReference()); NUnit.Framework.Assert.AreEqual(document, dictionary.GetIndirectReference().GetDocument()); } }
public virtual void SplitSentenceWithLineBreakTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] words = new char[] { (char)PdfFontUnitTest.TestFont.SIMPLE_GLYPH, '\n', (char)PdfFontUnitTest.TestFont .SIMPLE_GLYPH }; String wordsAsString = new String(words); double width = 10 * font.GetWidth(PdfFontUnitTest.TestFont.SIMPLE_GLYPH, FONT_SIZE); IList <String> result = font.SplitString(wordsAsString, FONT_SIZE, (float)width + 0.01f); NUnit.Framework.Assert.AreEqual(2, result.Count); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1)), result[0]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1)), result[1]); }
public virtual void SplitSentenceWordDoesNotFitMaxWidthCase_PartIsCombinedWithTheFollowingWordTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] words = GetSentence(3, 4, 2); String wordsAsString = new String(words); double width = 3 * font.GetWidth(PdfFontUnitTest.TestFont.SIMPLE_GLYPH, FONT_SIZE); IList <String> result = font.SplitString(wordsAsString, FONT_SIZE, (float)width + 0.01f); NUnit.Framework.Assert.AreEqual(3, result.Count); NUnit.Framework.Assert.AreEqual(new String(GetSentence(3)), result[0]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(3)), result[1]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1, 2)), result[2]); }
public virtual void AddSubsetRangeTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); font.SetSubset(false); int[] range1 = new int[] { 1, 2 }; int[] range2 = new int[] { 10, 20 }; font.AddSubsetRange(range1); font.AddSubsetRange(range2); NUnit.Framework.Assert.IsTrue(font.IsSubset()); NUnit.Framework.Assert.AreEqual(2, font.subsetRanges.Count); NUnit.Framework.Assert.AreEqual(range1, font.subsetRanges[0]); NUnit.Framework.Assert.AreEqual(range2, font.subsetRanges[1]); }
public virtual void SplitSentenceSymbolDoesNotFitLineTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] words = GetSentence(3); String wordsAsString = new String(words); double width = font.GetWidth(PdfFontUnitTest.TestFont.SIMPLE_GLYPH, FONT_SIZE) / 2.0; IList <String> result = font.SplitString(wordsAsString, FONT_SIZE, (float)width + 0.01f); NUnit.Framework.Assert.AreEqual(4, result.Count); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1)), result[0]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1)), result[1]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(1)), result[2]); NUnit.Framework.Assert.AreEqual(new String(GetSentence(0)), result[3]); }
public virtual void GetPdfStreamTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); byte[] data = new byte[10]; for (int i = 0; i < 10; i++) { data[i] = (byte)i; } int[] fontStreamLength = new int[] { 10, 20, 30 }; PdfStream stream = font.GetPdfFontStream(data, fontStreamLength); NUnit.Framework.Assert.AreEqual(data, stream.GetBytes()); NUnit.Framework.Assert.AreEqual(10, stream.GetAsNumber(new PdfName("Length1")).IntValue()); NUnit.Framework.Assert.AreEqual(20, stream.GetAsNumber(new PdfName("Length2")).IntValue()); NUnit.Framework.Assert.AreEqual(30, stream.GetAsNumber(new PdfName("Length3")).IntValue()); }
public virtual void ToStringTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual("PdfFont{fontProgram=" + font.fontProgram + "}", font.ToString()); }
public virtual void IsWrappedObjectMustBeIndirectTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.IsTrue(font.IsWrappedObjectMustBeIndirect()); }
public virtual void IsBuiltWithTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.IsFalse(font.IsBuiltWith("Any String Here", "Any Encoding")); }
public virtual void GetDescentOfUnknownGlyphTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual(0, font.GetDescent(111, 50)); }
public virtual void DescentCannotBePositiveTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual(0, font.GetDescent(PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WITH_POSITIVE_DESCENT , 50)); }
public virtual void GetFontMatrixTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual(PdfFont.DEFAULT_FONT_MATRIX, font.GetFontMatrix()); }
public virtual void ContainsGlyphTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.IsTrue(font.ContainsGlyph(PdfFontUnitTest.TestFont.SIMPLE_GLYPH)); NUnit.Framework.Assert.IsFalse(font.ContainsGlyph(111)); }
public virtual void ConstructorWithoutParamsTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual(PdfName.Font, font.GetPdfObject().Get(PdfName.Type)); }