@@ -57,7 +57,6 @@ This file is part of the iText (R) project.
57
57
import com .itextpdf .io .util .MessageFormatUtil ;
58
58
import com .itextpdf .io .util .StreamUtil ;
59
59
import com .itextpdf .kernel .colors .ColorConstants ;
60
- import com .itextpdf .kernel .colors .DeviceRgb ;
61
60
import com .itextpdf .kernel .font .PdfFont ;
62
61
import com .itextpdf .kernel .font .PdfFontFactory ;
63
62
import com .itextpdf .kernel .font .PdfTrueTypeFont ;
@@ -66,6 +65,7 @@ This file is part of the iText (R) project.
66
65
import com .itextpdf .kernel .font .PdfType3Font ;
67
66
import com .itextpdf .kernel .font .Type3FontProgram ;
68
67
import com .itextpdf .kernel .font .Type3Glyph ;
68
+ import com .itextpdf .kernel .geom .PageSize ;
69
69
import com .itextpdf .kernel .pdf .canvas .PdfCanvas ;
70
70
import com .itextpdf .kernel .utils .CompareTool ;
71
71
import com .itextpdf .test .ExtendedITextTest ;
@@ -1648,6 +1648,55 @@ public void SourceHanSerifKRRegularFullTest() throws IOException, InterruptedExc
1648
1648
Assert .assertNull (new CompareTool ().compareByContent (filename , cmpFilename , destinationFolder , "diff_" ));
1649
1649
}
1650
1650
1651
+ @ Test
1652
+ public void testFontStyleProcessing () throws IOException , InterruptedException {
1653
+ String filename = destinationFolder + "testFontStyleProcessing.pdf" ;
1654
+ String cmpFilename = sourceFolder + "cmp_testFontStyleProcessing.pdf" ;
1655
+
1656
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (filename ));
1657
+ PdfFont romanDefault = PdfFontFactory .createRegisteredFont ("Times-Roman" , PdfEncodings .WINANSI , false );
1658
+ PdfFont romanNormal = PdfFontFactory .createRegisteredFont ("Times-Roman" , PdfEncodings .WINANSI , false , FontConstants .NORMAL );
1659
+ PdfFont romanBold = PdfFontFactory .createRegisteredFont ("Times-Roman" , PdfEncodings .WINANSI , false , FontConstants .BOLD );
1660
+ PdfFont romanItalic = PdfFontFactory .createRegisteredFont ("Times-Roman" , PdfEncodings .WINANSI , false , FontConstants .ITALIC );
1661
+ PdfFont romanBoldItalic = PdfFontFactory .createRegisteredFont ("Times-Roman" , PdfEncodings .WINANSI , false , FontConstants .BOLDITALIC );
1662
+
1663
+ PdfPage page = pdfDoc .addNewPage (PageSize .A4 .rotate ());
1664
+ PdfCanvas canvas = new PdfCanvas (page );
1665
+ canvas
1666
+ .saveState ()
1667
+ .beginText ()
1668
+ .moveText (36 , 400 )
1669
+ .setFontAndSize (romanDefault , 72 )
1670
+ .showText ("Times-Roman default" )
1671
+ .endText ()
1672
+ .beginText ()
1673
+ .moveText (36 , 350 )
1674
+ .setFontAndSize (romanNormal , 72 )
1675
+ .showText ("Times-Roman normal" )
1676
+ .endText ()
1677
+ .beginText ()
1678
+ .moveText (36 , 300 )
1679
+ .setFontAndSize (romanBold , 72 )
1680
+ .showText ("Times-Roman bold" )
1681
+ .endText ()
1682
+ .beginText ()
1683
+ .moveText (36 , 250 )
1684
+ .setFontAndSize (romanItalic , 72 )
1685
+ .showText ("Times-Roman italic" )
1686
+ .endText ()
1687
+ .beginText ()
1688
+ .moveText (36 , 200 )
1689
+ .setFontAndSize (romanBoldItalic , 72 )
1690
+ .showText ("Times-Roman bolditalic" )
1691
+ .endText ()
1692
+ .restoreState ();
1693
+
1694
+ canvas .release ();
1695
+ page .flush ();
1696
+ pdfDoc .close ();
1697
+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpFilename , destinationFolder , "diff_" ));
1698
+ }
1699
+
1651
1700
@ Test
1652
1701
public void testCheckTTCSize () throws IOException {
1653
1702
TrueTypeCollection collection = new TrueTypeCollection (fontsFolder + "uming.ttc" );
0 commit comments