public void RenderTextPath(DrawingContext dc, PathGeometry pathGeometry, TextAlignment pathAlignment) { if (_pathChars == null) { throw new InvalidOperationException(); } if (_pathChars.Count == 0) { return; } //ISvgAnimatedLength pathOffset = _svgElement.StartOffset; SvgTextPathMethod pathMethod = (SvgTextPathMethod)_textPathElement.Method.BaseVal; SvgTextPathSpacing pathSpacing = (SvgTextPathSpacing)_textPathElement.Spacing.BaseVal; ISvgAnimatedLength pathOffset = this.GetPathOffset(); if (pathOffset != null && pathOffset.AnimVal.Value < 0) { this.RenderEndAlignedText(dc, pathGeometry, pathOffset); } else { if (pathAlignment == TextAlignment.Right) { this.RenderEndAlignedText(dc, pathGeometry, pathOffset); } else { this.RenderStartAlignedText(dc, pathGeometry, pathOffset, pathAlignment); } } }
public void DrawTextPath(DrawingContext dc, PathGeometry pathGeometry, ISvgAnimatedLength startOffset, TextAlignment alignment, SvgTextPathMethod method, SvgTextPathSpacing spacing) { if (alignment == TextAlignment.Right) { this.DrawEndAlignedTextPath(dc, pathGeometry, startOffset); } else { this.DrawStartAlignedTextPath(dc, pathGeometry, startOffset, alignment); } }
private void RenderTextPath(SvgTextPathElement textPath, ref Point ctp, double rotate, WpfTextPlacement placement) { if (textPath.ChildNodes == null || textPath.ChildNodes.Count == 0) { return; } SvgElement targetPath = textPath.ReferencedElement as SvgElement; if (targetPath == null) { return; } PathGeometry pathGeometry = CreateGeometry(targetPath, true) as PathGeometry; if (pathGeometry == null) { return; } this.IsTextPath = true; WpfTextOnPathDrawing pathDrawing = new WpfTextOnPathDrawing(); pathDrawing.BeginTextPath(); XmlNodeType nodeType = XmlNodeType.None; foreach (XmlNode child in textPath.ChildNodes) { nodeType = child.NodeType; if (nodeType == XmlNodeType.Text) { RenderTextPath(textPath, pathDrawing, GetText(textPath, child), new Point(ctp.X, ctp.Y), rotate, placement); } else if (nodeType == XmlNodeType.Element) { string nodeName = child.Name; if (string.Equals(nodeName, "tref")) { RenderTRefPath((SvgTRefElement)child, pathDrawing, ref ctp); } else if (string.Equals(nodeName, "tspan")) { RenderTSpanPath((SvgTSpanElement)child, pathDrawing, ref ctp); } } } WpfTextStringFormat stringFormat = GetTextStringFormat(_textElement); ISvgAnimatedLength pathOffset = textPath.StartOffset; SvgTextPathMethod pathMethod = (SvgTextPathMethod)textPath.Method.BaseVal; SvgTextPathSpacing pathSpacing = (SvgTextPathSpacing)textPath.Spacing.BaseVal; pathDrawing.DrawTextPath(_textContext, pathGeometry, pathOffset, stringFormat.Alignment, pathMethod, pathSpacing); pathDrawing.EndTextPath(); }