/// <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);
        }
        /// <summary>
        /// Add characters to the line(s), and returns the last width of the characters that were laid out.
        /// </summary>
        protected virtual PDFUnit AddProxyCharacters(PDFTextProxyOp proxy)
        {
            this.AssertCurrentLine();


            PDFUnit         lineheight = this.TextRenderOptions.GetLineHeight();
            ZeroLineCounter zeros      = new ZeroLineCounter();

            PDFSize measured = PDFSize.Empty;
            PDFSize required = PDFSize.Empty;

            PDFLayoutLine   line = this.CurrentLine;
            PDFLayoutRegion reg  = line.Region;

            PDFUnit availH = reg.AvailableHeight;
            PDFUnit availW = line.AvailableWidth;


            if (availH < lineheight)
            {
                if (this.Position.OverflowAction != OverflowAction.Clip)
                {
                    availH = lineheight;
                }
                else
                {
                    this.DoMoveToNextRegion(lineheight);

                    if (!this.ContinueLayout)
                    {
                        return(PDFUnit.Zero);
                    }
                }
            }

            //Measure the string an get the fitted characters

            int fitted;

            this.Context.PerformanceMonitor.Begin(PerformanceMonitorType.Text_Measure);

            measured = this.MeasureString(availH, availW, proxy.Text, 0, out fitted);

            this.Context.PerformanceMonitor.End(PerformanceMonitorType.Text_Measure);

            required = new PDFSize(measured.Width, lineheight);

            if (fitted < proxy.Text.Length) //cannot split a proxy - must simply be a single run.
            {
                //try on the next line to see if we can put everything on there.
                this.AddSoftReturn(0);

                if (!zeros.AssertIncrement(this.Context))
                {
                    return(PDFUnit.Zero);
                }

                availW = this.CurrentLine.AvailableWidth;

                this.Context.PerformanceMonitor.Begin(PerformanceMonitorType.Text_Measure);

                measured = this.MeasureString(availH, availW, proxy.Text, 0, out fitted);

                this.Context.PerformanceMonitor.End(PerformanceMonitorType.Text_Measure);

                if (fitted < proxy.Text.Length) //Still cannot fit the proxy so not much we can do. Log it and return
                {
                    this.Context.TraceLog.Add(TraceLevel.Warning, LOG_CATEGORY, "The text proxy  for '" + proxy.Text + "' could not fit the characters on a single line. Overflow of proxies is not currently supported.");
                    return(measured.Width);
                }

                required = new PDFSize(measured.Width, lineheight);
            }

            // everything fitted on the line

            zeros.Reset();
            this.AddProxyToCurrentLine(required, proxy);


            return(required.Width);
        }