SharpVectors.Dom.Svg.SvgTextContentElement.GetGraphicsPath C# (CSharp) Method

GetGraphicsPath() public method

public GetGraphicsPath ( ) : GraphicsPath
return System.Drawing.Drawing2D.GraphicsPath
        public virtual GraphicsPath GetGraphicsPath()
        {
            if(gp == null)
            {
                this.OwnerTextElement.GetGraphicsPath();
            }

            return gp;
        }

Same methods

SvgTextContentElement::GetGraphicsPath ( PointF &ctp ) : void

Usage Example

Example #1
0
        protected virtual void GetGraphicsPath(ref PointF ctp)
        {
            gp = new GraphicsPath();

            if (this is SvgTextPositioningElement)
            {
                SvgTextPositioningElement tpElm = (SvgTextPositioningElement)this;
                ctp = this.GetCurrentTextPosition(tpElm, ctp);
            }
            string sBaselineShift = GetPropertyValue("baseline-shift").Trim();
            double shiftBy        = 0;

            if (sBaselineShift.Length > 0)
            {
                SvgTextElement textElement = this as SvgTextElement;
                if (textElement == null)
                {
                    textElement = (SvgTextElement)this.SelectSingleNode("ancestor::svg:text", this.OwnerDocument.NamespaceManager);
                }

                float textFontSize = textElement._getComputedFontSize();
                if (sBaselineShift.EndsWith("%"))
                {
                    shiftBy = SvgNumber.ParseToFloat(sBaselineShift.Substring(0, sBaselineShift.Length - 1)) / 100 * textFontSize;
                }
                else if (sBaselineShift == "sub")
                {
                    shiftBy = -0.6F * textFontSize;
                }
                else if (sBaselineShift == "super")
                {
                    shiftBy = 0.6F * textFontSize;
                }
                else if (sBaselineShift == "baseline")
                {
                    shiftBy = 0;
                }
                else
                {
                    shiftBy = SvgNumber.ParseToFloat(sBaselineShift);
                }
            }


            foreach (XmlNode child in this.ChildNodes)
            {
                gp.StartFigure();
                if (child.NodeType == XmlNodeType.Text)
                {
                    ctp.Y -= (float)shiftBy;
                    this.AddGraphicsPath(ref ctp, GetText(child));
                    ctp.Y += (float)shiftBy;
                }
                else if (child is SvgTRefElement)
                {
                    SvgTRefElement trChild = (SvgTRefElement)child;
                    trChild.GetGraphicsPath(ref ctp);
                }
                else if (child is SvgTextContentElement)
                {
                    SvgTextContentElement tcChild = (SvgTextContentElement)child;
                    tcChild.GetGraphicsPath(ref ctp);
                }
            }
        }