Skip to content

Commit 7f6c323

Browse files
Kate IvanovaiText-CI
authored andcommitted
Improve coverage for kernel/font/PdfType0Font
DEVSIX-4516 Autoported commit. Original commit hash: [50ebb1ad0]
1 parent eca2739 commit 7f6c323

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using iText.IO.Font;
3+
using iText.Kernel;
4+
using iText.Kernel.Pdf;
5+
using iText.Test;
6+
7+
namespace iText.Kernel.Font {
8+
public class PdfType0FontTest : ExtendedITextTest {
9+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
10+
.CurrentContext.TestDirectory) + "/resources/itext/kernel/font/PdfType0FontTest/";
11+
12+
[NUnit.Framework.Test]
13+
public virtual void TrueTypeFontAndCmapConstructorTest() {
14+
TrueTypeFont ttf = new TrueTypeFont(sourceFolder + "NotoSerif-Regular_v1.7.ttf");
15+
PdfType0Font type0Font = new PdfType0Font(ttf, PdfEncodings.IDENTITY_H);
16+
CMapEncoding cmap = type0Font.GetCmap();
17+
NUnit.Framework.Assert.IsNotNull(cmap);
18+
NUnit.Framework.Assert.IsTrue(cmap.IsDirect());
19+
NUnit.Framework.Assert.IsFalse(cmap.HasUniMap());
20+
NUnit.Framework.Assert.IsNull(cmap.GetUniMapName());
21+
NUnit.Framework.Assert.AreEqual("Adobe", cmap.GetRegistry());
22+
NUnit.Framework.Assert.AreEqual("Identity", cmap.GetOrdering());
23+
NUnit.Framework.Assert.AreEqual(0, cmap.GetSupplement());
24+
NUnit.Framework.Assert.AreEqual(PdfEncodings.IDENTITY_H, cmap.GetCmapName());
25+
}
26+
27+
[NUnit.Framework.Test]
28+
public virtual void UnsupportedCmapTest() {
29+
NUnit.Framework.Assert.That(() => {
30+
TrueTypeFont ttf = new TrueTypeFont(sourceFolder + "NotoSerif-Regular_v1.7.ttf");
31+
PdfType0Font type0Font = new PdfType0Font(ttf, PdfEncodings.WINANSI);
32+
}
33+
, NUnit.Framework.Throws.InstanceOf<PdfException>().With.Message.EqualTo(PdfException.OnlyIdentityCMapsSupportsWithTrueType))
34+
;
35+
}
36+
37+
[NUnit.Framework.Test]
38+
public virtual void DictionaryConstructorTest() {
39+
String filePath = sourceFolder + "documentWithType0Noto.pdf";
40+
PdfDocument pdfDocument = new PdfDocument(new PdfReader(filePath));
41+
PdfDictionary fontDict = pdfDocument.GetPage(1).GetResources().GetResource(PdfName.Font).GetAsDictionary(new
42+
PdfName("F1"));
43+
PdfType0Font type0Font = new PdfType0Font(fontDict);
44+
CMapEncoding cmap = type0Font.GetCmap();
45+
NUnit.Framework.Assert.IsNotNull(cmap);
46+
NUnit.Framework.Assert.IsTrue(cmap.IsDirect());
47+
NUnit.Framework.Assert.IsFalse(cmap.HasUniMap());
48+
NUnit.Framework.Assert.IsNull(cmap.GetUniMapName());
49+
NUnit.Framework.Assert.AreEqual("Adobe", cmap.GetRegistry());
50+
NUnit.Framework.Assert.AreEqual("Identity", cmap.GetOrdering());
51+
NUnit.Framework.Assert.AreEqual(0, cmap.GetSupplement());
52+
NUnit.Framework.Assert.AreEqual(PdfEncodings.IDENTITY_H, cmap.GetCmapName());
53+
}
54+
}
55+
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3eca7b5e528cb8d549408e03d7ed0b6608567803
1+
50ebb1ad0fb8ce3311789ce40e505d94ca547ac9

0 commit comments

Comments
 (0)