@@ -48,10 +48,12 @@ This file is part of the iText (R) project.
48
48
import com .itextpdf .kernel .pdf .PdfDocument ;
49
49
import com .itextpdf .kernel .pdf .PdfWriter ;
50
50
import com .itextpdf .layout .Document ;
51
+ import com .itextpdf .layout .element .Paragraph ;
51
52
import com .itextpdf .layout .element .Text ;
52
53
import com .itextpdf .layout .font .FontProvider ;
53
54
import com .itextpdf .layout .layout .LayoutArea ;
54
55
import com .itextpdf .layout .layout .LayoutContext ;
56
+ import com .itextpdf .layout .layout .LayoutPosition ;
55
57
import com .itextpdf .layout .layout .LayoutResult ;
56
58
import com .itextpdf .layout .property .Property ;
57
59
import com .itextpdf .test .ExtendedITextTest ;
@@ -105,4 +107,23 @@ public void setTextException() {
105
107
rend .setText (val );
106
108
Assert .assertEquals (val , rend .getText ().toString ());
107
109
}
110
+
111
+ @ Test
112
+ @ LogMessages (messages = {
113
+ @ LogMessage (messageTemplate = LogMessageConstant .FONT_PROPERTY_MUST_BE_PDF_FONT_OBJECT )
114
+ })
115
+ public void setFontAsText () {
116
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (new ByteBufferOutputStream ()));
117
+ pdfDoc .addNewPage ();
118
+ Document doc = new Document (pdfDoc );
119
+ Text txt = new Text ("text" );
120
+ txt .setProperty (Property .POSITION , LayoutPosition .ABSOLUTE );
121
+ txt .setProperty (Property .TOP , 5f );
122
+ FontProvider fp = new FontProvider ();
123
+ fp .addFont ("Helvetica" );
124
+ txt .setProperty (Property .FONT_PROVIDER , fp );
125
+ txt .setFont ("Helvetica" );
126
+ doc .add (new Paragraph ().add (txt ));
127
+ doc .close ();
128
+ }
108
129
}
0 commit comments