Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Feb 22, 2024
2 parents c5ab393 + 5ba0fe2 commit 4f80739
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ public virtual void SimpleParagraphTest() {
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf));
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
[NUnit.Framework.Test]
public virtual void SimpleParagraphWithUnderlineTest() {
String outPdf = DESTINATION_FOLDER + "simpleParagraphTest.pdf";
String cmpPdf = SOURCE_FOLDER + "cmp_simpleParagraphWithUnderlineTest.pdf";
PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outPdf, PdfUATestPdfDocument.CreateWriterProperties
()));
PdfFont font = PdfFontFactory.CreateFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED
);
Document doc = new Document(pdfDoc);
doc.Add(new Paragraph("Simple layout PDF/UA-1 with underline test").SetFont(font).SetUnderline());
doc.Close();
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"
));
NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf));
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android)
[NUnit.Framework.Test]
public virtual void SimpleBorderTest() {
Expand Down
Binary file not shown.
25 changes: 18 additions & 7 deletions itext/itext.layout/itext/layout/renderer/TextRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -911,24 +911,24 @@ public override void Draw(DrawContext drawContext) {
}
canvas.EndText().RestoreState();
EndElementOpacityApplying(drawContext);
if (isTagged) {
canvas.CloseTag();
}
Object underlines = this.GetProperty<Object>(Property.UNDERLINE);
if (underlines is IList) {
foreach (Object underline in (IList)underlines) {
if (underline is Underline) {
DrawSingleUnderline((Underline)underline, fontColor, canvas, fontSize.GetValue(), italicSimulation ? ITALIC_ANGLE
: 0);
DrawAndTagSingleUnderline(drawContext.IsTaggingEnabled(), (Underline)underline, fontColor, canvas, fontSize
.GetValue(), italicSimulation ? ITALIC_ANGLE : 0);
}
}
}
else {
if (underlines is Underline) {
DrawSingleUnderline((Underline)underlines, fontColor, canvas, fontSize.GetValue(), italicSimulation ? ITALIC_ANGLE
: 0);
DrawAndTagSingleUnderline(drawContext.IsTaggingEnabled(), (Underline)underlines, fontColor, canvas, fontSize
.GetValue(), italicSimulation ? ITALIC_ANGLE : 0);
}
}
if (isTagged) {
canvas.CloseTag();
}
}
if (isRelativePosition) {
ApplyRelativePositioningTranslation(false);
Expand Down Expand Up @@ -1678,6 +1678,17 @@ internal virtual bool[] IsStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(ISpl
}
}

private void DrawAndTagSingleUnderline(bool isTagged, Underline underline, TransparentColor fontStrokeColor
, PdfCanvas canvas, float fontSize, float italicAngleTan) {
if (isTagged) {
canvas.OpenTag(new CanvasArtifact());
}
DrawSingleUnderline(underline, fontStrokeColor, canvas, fontSize, italicAngleTan);
if (isTagged) {
canvas.CloseTag();
}
}

private float GetCharWidth(Glyph g, float fontSize, float? hScale, float? characterSpacing, float? wordSpacing
) {
if (hScale == null) {
Expand Down
2 changes: 1 addition & 1 deletion port-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16ce4653542fa02480dd15063f1dd5cc0c874f54
38302fac797c3956c68cdfd02edba765ea311064

0 comments on commit 4f80739

Please sign in to comment.