Skip to content

Commit aa2b840

Browse files
Kate IvanovaiText-CI
Kate Ivanova
authored andcommitted
Verify TODO references, add TextWritingTest#leadingAndFloatInTextTest
DEVSIX-4574 Autoported commit. Original commit hash: [6a1962d6d]
1 parent f569813 commit aa2b840

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

itext.tests/itext.layout.tests/itext/layout/TextWritingTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ source product.
4747
using iText.Kernel.Pdf;
4848
using iText.Kernel.Pdf.Canvas;
4949
using iText.Kernel.Utils;
50+
using iText.Layout.Borders;
5051
using iText.Layout.Element;
5152
using iText.Layout.Properties;
5253
using iText.Test;
@@ -59,6 +60,9 @@ public class TextWritingTest : ExtendedITextTest {
5960
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
6061
+ "/test/itext/layout/TextWritingTest/";
6162

63+
public static readonly String fontsFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
64+
.CurrentContext.TestDirectory) + "/resources/itext/layout/fonts/";
65+
6266
[NUnit.Framework.OneTimeSetUp]
6367
public static void BeforeClass() {
6468
CreateDestinationFolder(destinationFolder);
@@ -308,5 +312,23 @@ public virtual void LineThroughTest() {
308312
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
309313
, "diff_"));
310314
}
315+
316+
[NUnit.Framework.Test]
317+
public virtual void LeadingAndFloatInTextTest() {
318+
// TODO: update cmp file after fixing DEVSIX-4604
319+
String outFileName = destinationFolder + "leadingAndFloatInText.pdf";
320+
String cmpFileName = sourceFolder + "cmp_leadingAndFloatInText.pdf";
321+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
322+
Document document = new Document(pdfDocument);
323+
Paragraph p = new Paragraph().SetFixedLeading(30).SetBorder(new SolidBorder(ColorConstants.RED, 2));
324+
p.Add("First text");
325+
Text text = new Text("Second text with float ");
326+
text.SetProperty(Property.FLOAT, FloatPropertyValue.LEFT);
327+
p.Add(text);
328+
document.Add(p);
329+
document.Close();
330+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
331+
));
332+
}
311333
}
312334
}

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,6 @@ protected internal virtual void ApplyLeading(float deltaY) {
909909
}
910910
}
911911

912-
// 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)
913912
protected internal virtual LineRenderer TrimLast() {
914913
int lastIndex = childRenderers.Count;
915914
IRenderer lastRenderer = null;
@@ -1065,29 +1064,22 @@ private void AdjustLineOnFloatPlaced(Rectangle layoutBox, int childPos, FloatPro
10651064
()) {
10661065
return;
10671066
}
1068-
// TODO handle it
1069-
bool ltr = true;
10701067
float floatWidth = justPlacedFloatBox.GetWidth();
10711068
if (kidFloatPropertyVal.Equals(FloatPropertyValue.LEFT)) {
10721069
layoutBox.SetWidth(layoutBox.GetWidth() - floatWidth).MoveRight(floatWidth);
10731070
occupiedArea.GetBBox().MoveRight(floatWidth);
1074-
if (ltr) {
1075-
for (int i = 0; i < childPos; ++i) {
1076-
IRenderer prevChild = childRenderers[i];
1077-
if (!FloatingHelper.IsRendererFloating(prevChild)) {
1078-
prevChild.Move(floatWidth, 0);
1079-
}
1071+
for (int i = 0; i < childPos; ++i) {
1072+
IRenderer prevChild = childRenderers[i];
1073+
if (!FloatingHelper.IsRendererFloating(prevChild)) {
1074+
prevChild.Move(floatWidth, 0);
10801075
}
10811076
}
10821077
}
10831078
else {
10841079
layoutBox.SetWidth(layoutBox.GetWidth() - floatWidth);
1085-
if (!ltr) {
1086-
}
10871080
}
10881081
}
10891082

1090-
// TODO
10911083
private void ReplaceSplitRendererKidFloats(IDictionary<int, IRenderer> floatsToNextPageSplitRenderers, LineRenderer
10921084
splitRenderer) {
10931085
foreach (KeyValuePair<int, IRenderer> splitFloat in floatsToNextPageSplitRenderers) {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9ce4248245a3a7c8fdbe3b6df576b6843ef90b69
1+
6a1962d6d00ba5adb620b7e73b979fdaec3c641b

0 commit comments

Comments
 (0)