Skip to content

Commit e73f534

Browse files
committed
Add a test to show an issue with a unicode-range and wrongly selected font, add a test for testing fonts with unicode range
DEVSIX-7022
1 parent c85efb8 commit e73f534

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

layout/src/test/java/com/itextpdf/layout/FontSelectorTest.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,53 @@ public void cyrillicAndLatinWithUnicodeRange() throws Exception {
487487
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName));
488488
}
489489

490+
@Test
491+
// TODO update cmp after fix DEVSIX-2052
492+
public void notSignificantCharacterOfTheFontWithUnicodeRange() throws Exception {
493+
String outFileName = destinationFolder + "notSignificantCharacterOfTheFontWithUnicodeRange.pdf";
494+
String cmpFileName = sourceFolder + "cmp_notSignificantCharacterOfTheFontWithUnicodeRange.pdf";
495+
496+
FontProvider sel = new FontProvider();
497+
Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(117, 117).create())); // just 'u' letter
498+
Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(106, 113).create()));// 'j', 'm' and 'p' are in that interval
499+
500+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
501+
Document doc = new Document(pdfDoc);
502+
503+
doc.setFontProvider(sel);
504+
doc.setProperty(Property.FONT, new String[] {"FontAlias"});
505+
506+
doc.add(new Paragraph("jump"));
507+
508+
doc.close();
509+
510+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
511+
}
512+
513+
@Test
514+
// TODO update cmp after fix DEVSIX-2052
515+
public void checkThreeFontsInOneLineWithUnicodeRange() throws Exception {
516+
String outFileName = destinationFolder + "checkThreeFontsInOneLineWithUnicodeRange.pdf";
517+
String cmpFileName = sourceFolder + "cmp_checkThreeFontsInOneLineWithUnicodeRange.pdf";
518+
519+
FontProvider sel = new FontProvider();
520+
Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(97, 99).create())); // 'a', 'b' and 'c' are in that interval
521+
Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(100, 102).create()));// 'd', 'e' and 'f' are in that interval
522+
Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", null, "FontAlias", new RangeBuilder(120, 122).create()));// 'x', 'y' and 'z' are in that interval
523+
524+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
525+
Document doc = new Document(pdfDoc);
526+
527+
doc.setFontProvider(sel);
528+
doc.setProperty(Property.FONT, new String[] {"FontAlias"});
529+
530+
doc.add(new Paragraph("abc def xyz"));
531+
532+
doc.close();
533+
534+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
535+
}
536+
490537
@Test
491538
public void duplicateFontWithUnicodeRange() throws Exception {
492539
String fileName = "duplicateFontWithUnicodeRange";

0 commit comments

Comments
 (0)