Skip to content

Commit 5665423

Browse files
Artyom YanchevskyiText-CI
authored andcommitted
Add test for CFFFontTest
DEVSIX-4987 Autoported commit. Original commit hash: [892d2e317]
1 parent f9186ab commit 5665423

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Please notice that the following fonts (including their different versions) are published under the following licenses:
2+
3+
* NotoSansCJKjp-Bold - SIL Open Font License v1.1
4+
5+
Please follow the link http://scripts.sil.org/OFL for more information. You can also observe the text of the license within current repository.

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
575737a49f3ed601a38ee90b13b7a17bb2d2baa5
1+
892d2e31789ae69de03eeb44f48cf3abe1d49be0

0 commit comments

Comments
 (0)