/// <summary> /// Creates a new Text character run and adds it to the current line. /// </summary> /// <param name="size">the size of the run in PDFUnits</param> /// <param name="chars">The characters that should be rendered in the run</param> private void AddProxyToCurrentLine(PDFSize size, PDFTextProxyOp op) { this.AssertCurrentLine(); PDFTextRunProxy run = new PDFTextRunProxy(size, op, this.CurrentLine, this.TextComponent); this.CurrentLine.AddRun(run); }
protected virtual void RenderTextDecoration(PDFTextRunEnd endRun, PDFRenderContext context, PDFWriter writer, PDFUnit vOffset, PDFUnit linethickness) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Debug, "Text Decoration", "Starting to render text decorations"); } //set up the graphics context PDFPen pen = PDFPen.Create(this.TextRenderOptions.FillBrush, linethickness); context.Graphics.SaveGraphicsState(); pen.SetUpGraphics(context.Graphics, this.TotalBounds); bool drawing = false; PDFPoint linestart = new PDFPoint(this.StartTextCursor.Width, this.StartTextCursor.Height + vOffset); foreach (PDFLayoutLine line in this.Lines) { PDFUnit linewidth = 0; foreach (PDFLayoutRun run in line.Runs) { if (run == this) { drawing = true; //lineoffset += this.LineInset; } else if (run == endRun) { drawing = false; break; } else if (drawing) { if (run is PDFTextRunCharacter) { PDFTextRunCharacter chars = (PDFTextRunCharacter)run; PDFPoint start = new PDFPoint(linestart.X + linewidth, linestart.Y); PDFPoint end = new PDFPoint(linestart.X + linewidth + chars.Width + chars.ExtraSpace, linestart.Y); context.Graphics.DrawLine(start, end); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Text Decoration", "Drawn line from " + start + " to " + end); } linewidth += chars.Width; } else if (run is PDFTextRunEnd) { } else if (run is PDFTextRunNewLine) { PDFTextRunNewLine newline = (PDFTextRunNewLine)run; PDFSize offset = newline.Offset; if (null != newline.NextLineSpacer) { PDFUnit nextoffset = newline.NextLineSpacer.Width; offset.Width = nextoffset - offset.Width; } linestart.X += offset.Width; linestart.Y += offset.Height; } else if (run is PDFTextRunSpacer) { //PDFTextRunSpacer spacer = (PDFTextRunSpacer)run; //cursor.X += spacer.Width; } else if (run is PDFTextRunProxy) { PDFTextRunProxy chars = (PDFTextRunProxy)run; PDFPoint start = new PDFPoint(linestart.X + linewidth, linestart.Y); PDFPoint end = new PDFPoint(linestart.X + linewidth + chars.Width, linestart.Y); context.Graphics.DrawLine(start, end); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Text Decoration", "Drawn line from " + start + " to " + end); } linewidth += chars.Width; } } } } if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Debug, "Text Decoration", "Completed the renderering of text decorations"); } //tear down the current graphics state context.Graphics.RestoreGraphicsState(); }