|
| 1 | +using System; |
| 2 | +using iText.IO.Source; |
| 3 | +using iText.Test; |
| 4 | + |
| 5 | +namespace iText.IO.Font { |
| 6 | + public class CFFFontTest : ExtendedITextTest { |
| 7 | + private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext |
| 8 | + .CurrentContext.TestDirectory) + "/resources/itext/io/font/otf/CFFFontTest/"; |
| 9 | + |
| 10 | + [NUnit.Framework.Test] |
| 11 | + public virtual void SeekTest() { |
| 12 | + RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateBestSource |
| 13 | + (SOURCE_FOLDER + "NotoSansCJKjp-Bold.otf")); |
| 14 | + byte[] cff = new byte[16014190]; |
| 15 | + try { |
| 16 | + raf.Seek(283192); |
| 17 | + raf.ReadFully(cff); |
| 18 | + } |
| 19 | + finally { |
| 20 | + raf.Close(); |
| 21 | + } |
| 22 | + CFFFont cffFont = new CFFFont(cff); |
| 23 | + cffFont.Seek(0); |
| 24 | + // Get int (bin 0000 0001 0000 0000 0000 0100 0000 0011) |
| 25 | + NUnit.Framework.Assert.AreEqual(16778243, cffFont.GetInt()); |
| 26 | + cffFont.Seek(0); |
| 27 | + // Gets the first short (bin 0000 0001 0000 0000) |
| 28 | + NUnit.Framework.Assert.AreEqual(256, cffFont.GetShort()); |
| 29 | + cffFont.Seek(2); |
| 30 | + // Gets the second short (bin 0000 0100 0000 0011) |
| 31 | + NUnit.Framework.Assert.AreEqual(1027, cffFont.GetShort()); |
| 32 | + } |
| 33 | + |
| 34 | + [NUnit.Framework.Test] |
| 35 | + public virtual void GetPositionTest() { |
| 36 | + RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateBestSource |
| 37 | + (SOURCE_FOLDER + "NotoSansCJKjp-Bold.otf")); |
| 38 | + byte[] cff = new byte[16014190]; |
| 39 | + try { |
| 40 | + raf.Seek(283192); |
| 41 | + raf.ReadFully(cff); |
| 42 | + } |
| 43 | + finally { |
| 44 | + raf.Close(); |
| 45 | + } |
| 46 | + CFFFont cffFont = new CFFFont(cff); |
| 47 | + cffFont.Seek(0); |
| 48 | + NUnit.Framework.Assert.AreEqual(0, cffFont.GetPosition()); |
| 49 | + cffFont.Seek(16); |
| 50 | + NUnit.Framework.Assert.AreEqual(16, cffFont.GetPosition()); |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments