File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
main/java/com/itextpdf/io/font
test/java/com/itextpdf/io/font Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,11 @@ protected void setFixedPitch(boolean isFixedPitch) {
215215 }
216216
217217 protected void setBold (boolean isBold ) {
218- fontNames .setMacStyle (fontNames .getMacStyle () | FontNames .BOLD_FLAG );
218+ if (isBold ) {
219+ fontNames .setMacStyle (fontNames .getMacStyle () | FontNames .BOLD_FLAG );
220+ } else {
221+ fontNames .setMacStyle (fontNames .getMacStyle () & (~FontNames .BOLD_FLAG ));
222+ }
219223 }
220224
221225 protected void setBbox (int [] bbox ) {
Original file line number Diff line number Diff line change 88import java .io .IOException ;
99
1010@ Category (UnitTest .class )
11- public class FontFactoryTest {
11+ public class FontProgramTest {
1212
1313 @ Test
1414 public void exceptionMessageTest () throws IOException {
@@ -18,4 +18,13 @@ public void exceptionMessageTest() throws IOException {
1818 Assert .assertEquals ("font.file some-font.ttf not.found" , ex .getMessage ());
1919 }
2020 }
21+
22+ @ Test
23+ public void boldTest () throws IOException {
24+ FontProgram fp = FontFactory .createFont (FontConstants .HELVETICA );
25+ fp .setBold (true );
26+ Assert .assertTrue ("Bold expected" , (fp .getPdfFontFlags () & (1 << 18 )) != 0 );
27+ fp .setBold (false );
28+ Assert .assertTrue ("Not Bold expected" , (fp .getPdfFontFlags () & (1 << 18 )) == 0 );
29+ }
2130}
You can’t perform that action at this time.
0 commit comments