Skip to content

Commit 6a1962d

Browse files
Kate IvanovaiText-CI
authored andcommitted
Verify TODO references, add TextWritingTest#leadingAndFloatInTextTest
DEVSIX-4574
1 parent 9ce4248 commit 6a1962d

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/LineRenderer.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ protected void applyLeading(float deltaY) {
917917
if (!FloatingHelper.isRendererFloating(child)) {
918918
child.move(0, deltaY);
919919
}
920-
// TODO for floats we don't apply any leading for the moment (and therefore line-height for pdf2html is not entirely supported in terms of floats)
921920
}
922921
}
923922

@@ -1050,25 +1049,19 @@ private void adjustLineOnFloatPlaced(Rectangle layoutBox, int childPos, FloatPro
10501049
return;
10511050
}
10521051

1053-
// TODO handle it
1054-
boolean ltr = true;
10551052
float floatWidth = justPlacedFloatBox.getWidth();
10561053
if (kidFloatPropertyVal.equals(FloatPropertyValue.LEFT)) {
10571054
layoutBox.setWidth(layoutBox.getWidth() - floatWidth).moveRight(floatWidth);
10581055
occupiedArea.getBBox().moveRight(floatWidth);
1059-
if (ltr) {
10601056
for (int i = 0; i < childPos; ++i) {
10611057
IRenderer prevChild = childRenderers.get(i);
10621058
if (!FloatingHelper.isRendererFloating(prevChild)) {
10631059
prevChild.move(floatWidth, 0);
10641060
}
10651061
}
1066-
}
1062+
10671063
} else {
10681064
layoutBox.setWidth(layoutBox.getWidth() - floatWidth);
1069-
if (!ltr) {
1070-
// TODO
1071-
}
10721065
}
10731066
}
10741067

layout/src/test/java/com/itextpdf/layout/TextWritingTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ This file is part of the iText (R) project.
5050
import com.itextpdf.kernel.pdf.PdfWriter;
5151
import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants;
5252
import com.itextpdf.kernel.utils.CompareTool;
53+
import com.itextpdf.layout.borders.SolidBorder;
5354
import com.itextpdf.layout.element.AreaBreak;
5455
import com.itextpdf.layout.element.Paragraph;
5556
import com.itextpdf.layout.element.Text;
57+
import com.itextpdf.layout.property.FloatPropertyValue;
5658
import com.itextpdf.layout.property.OverflowPropertyValue;
5759
import com.itextpdf.layout.property.Property;
60+
import com.itextpdf.layout.property.UnitValue;
5861
import com.itextpdf.test.ExtendedITextTest;
5962
import com.itextpdf.test.annotations.type.IntegrationTest;
6063
import org.junit.Assert;
@@ -69,6 +72,7 @@ public class TextWritingTest extends ExtendedITextTest {
6972

7073
public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TextWritingTest/";
7174
public static final String destinationFolder = "./target/test/com/itextpdf/layout/TextWritingTest/";
75+
public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/";
7276

7377
@BeforeClass
7478
public static void beforeClass() {
@@ -376,4 +380,28 @@ public void lineThroughTest() throws IOException, InterruptedException {
376380

377381
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_"));
378382
}
383+
384+
@Test
385+
// TODO: update cmp file after fixing DEVSIX-4604
386+
public void leadingAndFloatInTextTest() throws IOException, InterruptedException {
387+
String outFileName = destinationFolder + "leadingAndFloatInText.pdf";
388+
String cmpFileName = sourceFolder + "cmp_leadingAndFloatInText.pdf";
389+
390+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
391+
392+
Document document = new Document(pdfDocument);
393+
394+
Paragraph p = new Paragraph().setFixedLeading(30).setBorder(new SolidBorder(ColorConstants.RED, 2));
395+
p.add("First text");
396+
397+
Text text = new Text("Second text with float ");
398+
text.setProperty(Property.FLOAT, FloatPropertyValue.LEFT);
399+
400+
p.add(text);
401+
402+
document.add(p);
403+
document.close();
404+
405+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder));
406+
}
379407
}
1.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)