Skip to content

Commit 34fa1fe

Browse files
yulian-gaponenkoiText-CI
authored andcommitted
Consider not set LINE_HEIGHT property to be exactly the same as LineHeight.NORMAL
DEVSIX-3662 Autoported commit. Original commit hash: [91eaf54cc]
1 parent e462c81 commit 34fa1fe

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

itext.tests/itext.layout.tests/itext/layout/renderer/LineRendererUnitTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ source product.
4040
For more information, please contact iText Software Corp. at this
4141
4242
*/
43+
using iText.IO.Font.Constants;
4344
using iText.IO.Util;
45+
using iText.Kernel.Font;
4446
using iText.Kernel.Geom;
4547
using iText.Kernel.Pdf.Xobject;
4648
using iText.Layout;
@@ -228,5 +230,25 @@ public virtual void LineRendererLayoutInHtmlModeWithLineHeightAndChildInHtmlMode
228230
NUnit.Framework.Assert.AreEqual(28.67920f, lineRenderer.maxAscent, EPS);
229231
NUnit.Framework.Assert.AreEqual(-21.32080f, lineRenderer.maxDescent, EPS);
230232
}
233+
234+
[NUnit.Framework.Test]
235+
public virtual void LineRendererLayoutInHtmlModeWithLineHeightPropertyNotSet() {
236+
LineRenderer lineRenderer = new LineRenderer();
237+
lineRenderer.SetParent(CreateDocument().GetRenderer());
238+
lineRenderer.SetProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE);
239+
// Set fonts with different ascent/descent to line and text
240+
lineRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(StandardFonts.HELVETICA));
241+
TextRenderer textRenderer = new TextRenderer(new Text("text"));
242+
textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(StandardFonts.COURIER));
243+
lineRenderer.AddChild(textRenderer);
244+
LayoutResult layoutResLineHeightNotSet = lineRenderer.Layout(new LayoutContext(CreateLayoutArea(1000, 1000
245+
)));
246+
lineRenderer.SetProperty(Property.LINE_HEIGHT, LineHeight.CreateNormalValue());
247+
LayoutResult layoutResLineHeightNormal = lineRenderer.Layout(new LayoutContext(CreateLayoutArea(1000, 1000
248+
)));
249+
Rectangle bboxLineHeightNotSet = layoutResLineHeightNotSet.GetOccupiedArea().GetBBox();
250+
Rectangle bboxLineHeightNormal = layoutResLineHeightNormal.GetOccupiedArea().GetBBox();
251+
NUnit.Framework.Assert.IsTrue(bboxLineHeightNotSet.EqualsWithEpsilon(bboxLineHeightNormal));
252+
}
231253
}
232254
}

itext/itext.layout/itext/layout/renderer/LineRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
101101
GetHeight()).SetHeight(0).SetWidth(0));
102102
UpdateChildrenParent();
103103
float curWidth = 0;
104-
if (RenderingMode.HTML_MODE.Equals(this.GetProperty<RenderingMode?>(Property.RENDERING_MODE)) && HasProperty
105-
(Property.LINE_HEIGHT) && HasChildRendererInHtmlMode()) {
104+
if (RenderingMode.HTML_MODE.Equals(this.GetProperty<RenderingMode?>(Property.RENDERING_MODE)) && HasChildRendererInHtmlMode
105+
()) {
106106
float[] ascenderDescender = LineHeightHelper.GetActualAscenderDescender(this);
107107
maxAscent = ascenderDescender[0];
108108
maxDescent = ascenderDescender[1];

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
65011089bb7512af40c97fe2597e3d9d36e7dee8
1+
91eaf54cce38ee7a508fc4281bc268efefa19de1

0 commit comments

Comments
 (0)