Skip to content

Commit 2e81503

Browse files
committed
Add new test for writing text with CID font and variable code space lengths
DEVSIX-1058
1 parent d62ef44 commit 2e81503

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,37 @@ public void createDocumentWithKozmin() throws IOException, InterruptedException
132132
Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_"));
133133
}
134134

135+
@Test
136+
public void createDocumentWithKozminAndDifferentCodespaceRanges() throws IOException, InterruptedException {
137+
String filename = destinationFolder + "DocumentWithKozminDifferentCodespaceRanges.pdf";
138+
String cmpFilename = sourceFolder + "cmp_DocumentWithKozminDifferentCodespaceRanges.pdf";
139+
String title = "Type 0 test";
140+
141+
PdfWriter writer = new PdfWriter(filename);
142+
writer.setCompressionLevel(CompressionConstants.NO_COMPRESSION);
143+
PdfDocument pdfDoc = new PdfDocument(writer);
144+
145+
pdfDoc.getDocumentInfo().setAuthor(author).
146+
setCreator(creator).
147+
setTitle(title);
148+
PdfFont type0Font = PdfFontFactory.createFont("KozMinPro-Regular", "83pv-RKSJ-H", true);
149+
Assert.assertTrue("Type0Font expected", type0Font instanceof PdfType0Font);
150+
Assert.assertTrue("CidFont expected", type0Font.getFontProgram() instanceof CidFont);
151+
PdfPage page = pdfDoc.addNewPage();
152+
PdfCanvas canvas = new PdfCanvas(page);
153+
canvas.saveState()
154+
.beginText()
155+
.moveText(36, 700)
156+
.setFontAndSize(type0Font, 50)
157+
.showText(type0Font.createGlyphLine("Hello\u7121\u540dworld\u6b98\u528d"))
158+
.endText()
159+
.restoreState();
160+
canvas.release();
161+
page.flush();
162+
pdfDoc.close();
163+
Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_"));
164+
}
165+
135166
@Test
136167
public void createDocumentWithStSongUni() throws IOException, InterruptedException {
137168
String filename = destinationFolder + "DocumentWithStSongUni.pdf";

0 commit comments

Comments
 (0)