MigraDoc / PDFSharp 1.32
Calling
AddSpace at the start of a
FormattedText block results in the white-space inheriting the underline from the previous block.
Attachment:
File comment: Screen-shot of the bug in action
pdfsharp-underline-bug.png [ 39.64 KiB | Viewed 8961 times ]
To reproduce:
Code:
var para = section.AddParagraph();
var block = para.AddFormattedText();
block.Font.Underline = Underline.Single;
block.Add(new Text("This should be underlined"));
block = para.AddFormattedText();
block.Font.Underline = Underline.None;
block.AddSpace(10);
block.Add(new Text("<-- These spaces should not"));
The problem appears to be in the
RenderSpace method of the
ParagraphRenderer class. I was able to fix the bug by changing this method to:
Code:
void RenderSpace(Character character)
{
XUnit width = GetSpaceWidth(character);
RenderUnderline(width, false);
RealizeHyperlink(width);
this.currentXPosition += width;
}