@@ -43,6 +43,8 @@ This file is part of the iText (R) project.
43
43
package com .itextpdf .layout .renderer ;
44
44
45
45
import com .itextpdf .io .LogMessageConstant ;
46
+ import com .itextpdf .io .font .constants .StandardFonts ;
47
+ import com .itextpdf .kernel .font .PdfFontFactory ;
46
48
import com .itextpdf .kernel .geom .Rectangle ;
47
49
import com .itextpdf .kernel .pdf .xobject .PdfFormXObject ;
48
50
import com .itextpdf .layout .Document ;
@@ -61,6 +63,7 @@ This file is part of the iText (R) project.
61
63
import com .itextpdf .test .annotations .LogMessages ;
62
64
import com .itextpdf .test .annotations .type .UnitTest ;
63
65
66
+ import java .io .IOException ;
64
67
import java .util .Arrays ;
65
68
import org .junit .Assert ;
66
69
import org .junit .Test ;
@@ -279,4 +282,27 @@ public void lineRendererLayoutInHtmlModeWithLineHeightAndChildInHtmlModeTest() {
279
282
Assert .assertEquals (28.67920f , lineRenderer .maxAscent , EPS );
280
283
Assert .assertEquals (-21.32080f , lineRenderer .maxDescent , EPS );
281
284
}
285
+
286
+ @ Test
287
+ public void lineRendererLayoutInHtmlModeWithLineHeightPropertyNotSet () throws IOException {
288
+ LineRenderer lineRenderer = new LineRenderer ();
289
+ lineRenderer .setParent (createDocument ().getRenderer ());
290
+ lineRenderer .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
291
+
292
+ // Set fonts with different ascent/descent to line and text
293
+ lineRenderer .setProperty (Property .FONT , PdfFontFactory .createFont (StandardFonts .HELVETICA ));
294
+
295
+ TextRenderer textRenderer = new TextRenderer (new Text ("text" ));
296
+ textRenderer .setProperty (Property .FONT , PdfFontFactory .createFont (StandardFonts .COURIER ));
297
+
298
+ lineRenderer .addChild (textRenderer );
299
+ LayoutResult layoutResLineHeightNotSet = lineRenderer .layout (new LayoutContext (createLayoutArea (1000 , 1000 )));
300
+
301
+ lineRenderer .setProperty (Property .LINE_HEIGHT , LineHeight .createNormalValue ());
302
+ LayoutResult layoutResLineHeightNormal = lineRenderer .layout (new LayoutContext (createLayoutArea (1000 , 1000 )));
303
+
304
+ Rectangle bboxLineHeightNotSet = layoutResLineHeightNotSet .getOccupiedArea ().getBBox ();
305
+ Rectangle bboxLineHeightNormal = layoutResLineHeightNormal .getOccupiedArea ().getBBox ();
306
+ Assert .assertTrue (bboxLineHeightNotSet .equalsWithEpsilon (bboxLineHeightNormal ));
307
+ }
282
308
}
0 commit comments