File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
io/src/main/java/com/itextpdf/io
main/java/com/itextpdf/layout/renderer
test/java/com/itextpdf/layout/renderer Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public final class LogMessageConstant {
69
69
public static final String FILE_CHANNEL_CLOSING_FAILED = "Closing of the file channel this source is based on failed." ;
70
70
public static final String FONT_HAS_INVALID_GLYPH = "Font {0} has invalid glyph: {1}" ;
71
71
public static final String FORBID_RELEASE_IS_SET = "ForbidRelease flag is set and release is called. Releasing will not be performed." ;
72
+ public static final String FONT_PROPERTY_MUST_BE_PDF_FONT_OBJECT = "The Font Property must be a PdfFont object" ;
72
73
public static final String FORM_FIELD_WAS_FLUSHED = "A form field was flushed. There's no way to create this field in the AcroForm dictionary." ;
73
74
public static final String IMAGE_HAS_AMBIGUOUS_SCALE = "The image cannot be auto scaled and scaled by a certain parameter simultaneously" ;
74
75
public static final String IMAGE_HAS_JBIG2DECODE_FILTER = "Image cannot be inline if it has JBIG2Decode filter. It will be added as an ImageXObject" ;
Original file line number Diff line number Diff line change @@ -1259,7 +1259,14 @@ private boolean isGlyphPartOfWordForHyphenation(Glyph g) {
1259
1259
1260
1260
private void updateFontAndText () {
1261
1261
if (strToBeConverted != null ) {
1262
- font = resolveFirstPdfFont ();
1262
+ try {
1263
+ font = getPropertyAsFont (Property .FONT );
1264
+ }
1265
+ catch (ClassCastException cce ) {
1266
+ font = resolveFirstPdfFont ();
1267
+ Logger logger = LoggerFactory .getLogger (TextRenderer .class );
1268
+ logger .error (LogMessageConstant .FONT_PROPERTY_MUST_BE_PDF_FONT_OBJECT );
1269
+ }
1263
1270
text = convertToGlyphLine (strToBeConverted );
1264
1271
otfFeaturesApplied = false ;
1265
1272
strToBeConverted = null ;
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ This file is part of the iText (R) project.
42
42
*/
43
43
package com .itextpdf .layout .renderer ;
44
44
45
+ import com .itextpdf .io .LogMessageConstant ;
45
46
import com .itextpdf .kernel .geom .Rectangle ;
46
47
import com .itextpdf .kernel .pdf .ByteBufferOutputStream ;
47
48
import com .itextpdf .kernel .pdf .PdfDocument ;
@@ -54,6 +55,8 @@ This file is part of the iText (R) project.
54
55
import com .itextpdf .layout .layout .LayoutResult ;
55
56
import com .itextpdf .layout .property .Property ;
56
57
import com .itextpdf .test .ExtendedITextTest ;
58
+ import com .itextpdf .test .annotations .LogMessage ;
59
+ import com .itextpdf .test .annotations .LogMessages ;
57
60
import com .itextpdf .test .annotations .type .UnitTest ;
58
61
59
62
import org .junit .Assert ;
@@ -88,6 +91,9 @@ public void nextRendererTest() {
88
91
}
89
92
90
93
@ Test
94
+ @ LogMessages (messages = {
95
+ @ LogMessage (messageTemplate = LogMessageConstant .FONT_PROPERTY_MUST_BE_PDF_FONT_OBJECT )
96
+ })
91
97
public void setTextException () {
92
98
final String val = "other text" ;
93
99
final String fontName = "Helvetica" ;
You can’t perform that action at this time.
0 commit comments