public virtual void GetWidthFontSizeTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); double expectedValue = PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WIDTH * FONT_SIZE / (double)FontProgram.UNITS_NORMALIZATION; NUnit.Framework.Assert.AreEqual(expectedValue, font.GetWidth(PdfFontUnitTest.TestFont.SIMPLE_GLYPH, FONT_SIZE ), 0.1); NUnit.Framework.Assert.AreEqual(0, font.GetWidth(111)); }
public virtual void GetWidthUnicodeTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); NUnit.Framework.Assert.AreEqual(PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WIDTH, font.GetWidth(PdfFontUnitTest.TestFont .SIMPLE_GLYPH)); NUnit.Framework.Assert.AreEqual(0, font.GetWidth(111)); }
public virtual void GetWidthOfUnknownGlyphsTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] text = new char[] { (char)111, (char)222, (char)333 }; String textAsString = new String(text); NUnit.Framework.Assert.AreEqual(0, font.GetWidth(textAsString)); }
public virtual void GetWidthOfStringWithFontSizeTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] text = GetSentence(3); String textAsString = new String(text); double expectedValue = 3 * PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WIDTH * FONT_SIZE / (double)FontProgram.UNITS_NORMALIZATION; NUnit.Framework.Assert.AreEqual(expectedValue, font.GetWidth(textAsString, FONT_SIZE), 0.1); }
public virtual void GetWidthOfSurrogatePairTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] text = new char[] { PdfFontUnitTest.TestFont.COMPLEX_GLYPH_AS_CHARS[0], PdfFontUnitTest.TestFont.COMPLEX_GLYPH_AS_CHARS [1], (char)PdfFontUnitTest.TestFont.SIMPLE_GLYPH }; String textAsString = new String(text); NUnit.Framework.Assert.AreEqual(PdfFontUnitTest.TestFont.COMPLEX_GLYPH_WIDTH + PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WIDTH , font.GetWidth(textAsString)); }
public virtual void SplitSentenceFitMaxWidthTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] words = GetSentence(3, 3); String wordsAsString = new String(words); double width = 6 * font.GetWidth(PdfFontUnitTest.TestFont.SIMPLE_GLYPH, FONT_SIZE); IList <String> result = font.SplitString(wordsAsString, FONT_SIZE, (float)width + 0.01f); NUnit.Framework.Assert.AreEqual(1, result.Count); NUnit.Framework.Assert.AreEqual(wordsAsString, result[0]); }
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 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 GetWidthOfStringTest() { PdfFontUnitTest.TestFont font = new PdfFontUnitTest.TestFont(); char[] text = GetSentence(3); String textAsString = new String(text); NUnit.Framework.Assert.AreEqual(3 * PdfFontUnitTest.TestFont.SIMPLE_GLYPH_WIDTH, font.GetWidth(textAsString )); }