public WpfTextRendering(SvgElement element) : base(element) { _textElement = element as SvgTextElement; if (_textElement == null) { throw new InvalidOperationException(); } _horzRenderer = new WpfHorzTextRenderer(_textElement, this); _vertRenderer = new WpfVertTextRenderer(_textElement, this); _pathRenderer = new WpfPathTextRenderer(_textElement, this); }
protected WpfTextRenderer(SvgTextElement textElement, WpfTextRendering textRendering) { if (textElement == null) { throw new ArgumentNullException("textElement", "The SVG text element is required, and cannot be null (or Nothing)."); } if (textRendering == null) { throw new ArgumentNullException("textRendering", "The text rendering object is required, and cannot be null (or Nothing)."); } _textElement = textElement; _textRendering = textRendering; }
public WpfVertTextRenderer(SvgTextElement textElement, WpfTextRendering textRendering) : base(textElement, textRendering) { }
private void RenderTextPath(SvgTextElement element, SvgTextPathElement textPath, ref Point ctp, double rotate, WpfTextPlacement placement) { if (_pathRenderer == null) { return; } _pathRenderer.RenderSingleLineText(textPath, ref ctp, String.Empty, rotate, placement); }
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); } } }