/// <summary>
        /// Adds a spacer of the required width (and height) to the line - inheritors can override this value
        /// </summary>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="line"></param>
        protected virtual PDFTextRunSpacer AddLineInsetRun(PDFUnit w, PDFUnit h, PDFLayoutLine line)
        {
            PDFTextRunSpacer spacer = new PDFTextRunSpacer(w, h, line, this.TextComponent);

            line.AddRun(spacer);
            return(spacer);
        }
        /// <summary>
        /// We need to start the text
        /// </summary>
        protected virtual bool StartText()
        {
            if (this.Context.ShouldLogDebug)
            {
                this.Context.TraceLog.Begin(TraceLevel.Verbose, LOG_CATEGORY, "Starting the layout of text component " + this.TextComponent.ID);
            }
            bool          started;
            PDFLayoutLine line = this.EnsureFirstLineAvailable(out started);

            if (null == line)
            {
                this.ContinueLayout = false;
                return(false);
            }

            this.CurrentLine = line;

            this.Context.Graphics.SetCurrentFont(this.TextRenderOptions.Font);

            PDFUnit inset = PDFUnit.Zero;

            if (line.IsEmpty == false)
            {
                inset = line.Width;
            }
            else if (this.TextRenderOptions.FirstLineInset.HasValue && (this.Position.PositionMode != PositionMode.Inline || started))
            {
                inset = this.TextRenderOptions.FirstLineInset.Value;
                if (inset > 0)
                {
                    PDFTextRunSpacer spacer = new PDFTextRunSpacer(inset, 1, line, null);
                    line.AddRun(spacer);
                }
            }


            PDFTextRunBegin begin = new PDFTextRunBegin(this.TextRenderOptions, this.CurrentLine, this.TextComponent);

            begin.LineInset = inset;

            this.CurrentLine.AddRun(begin);
            begin.SetOffsetY(this.CurrentLine.OffsetY);


            this.CurrentLineInset = inset;
            this.BeginningRun     = begin;

            if (this.Context.ShouldLogDebug)
            {
                this.Context.TraceLog.End(TraceLevel.Verbose, LOG_CATEGORY, "Completed the layout of text component " + this.TextComponent.ID);
            }
            else if (this.Context.ShouldLogVerbose)
            {
                this.Context.TraceLog.Add(TraceLevel.Verbose, LOG_CATEGORY, "Laid out text component " + this.TextComponent.ID);
            }

            return(true);
        }
        protected virtual void AddReturn(PDFUnit widthOfLastTextDraw, bool hardReturn)
        {
            this.AssertCurrentLine();
            PDFLayoutLine     line = this.CurrentLine;
            PDFTextRunNewLine br   = new PDFTextRunNewLine(false, line, this.TextRenderOptions, this.TextComponent);


            line.AddRun(br);

            //The offset is from the start of the last text drawing operation
            //and the offset of the start of the current line
            PDFUnit lineright = widthOfLastTextDraw;

            PDFUnit back = line.Width - lineright;

            //Previous - 27 Feb 2015
            //br.Offset = new PDFSize(back, line.Height);

            //Updated
            if (line.BaseLineOffset == 0 || this.TextRenderOptions.Leading.HasValue) //we don't have any begins or ends affecting the flow (or an explicit leading)
            {
                br.Offset = new PDFSize(back, line.Height);
            }
            else
            {
                br.Offset = new PDFSize(back, (line.Height - line.BaseLineOffset) + this.TextRenderOptions.GetAscent());
            }


            PDFLayoutRegion reg = line.Region;

            reg.CloseCurrentItem();
            line = reg.BeginNewLine();
            this.BeginningRun.Lines.Add(line);

            PDFUnit inset;

            if (hardReturn)
            {
                inset = this.TextRenderOptions.GetFirstLineInset();
            }
            else
            {
                inset = PDFUnit.Zero;
            }

            PDFTextRunSpacer spacer = this.AddLineInsetRun(inset, 0, line);

            br.NextLineSpacer     = spacer;
            this.CurrentLine      = line;
            this.CurrentLineInset = inset;
        }