Path RenderSVGTextPath::layoutPath() const { Element* targetElement = SVGURIReference::targetElementFromIRIString(textPathElement().href(), document()); if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag)) return Path(); SVGPathElement* pathElement = toSVGPathElement(targetElement); Path pathData; updatePathFromGraphicsElement(pathElement, pathData); // Spec: The transform attribute on the referenced 'path' element represents a // supplemental transformation relative to the current user coordinate system for // the current 'text' element, including any adjustments to the current user coordinate // system due to a possible transform attribute on the current 'text' element. // http://www.w3.org/TR/SVG/text.html#TextPathElement pathData.transform(pathElement->animatedLocalTransform()); return pathData; }
void SkSVGDevice::drawTextOnPath(const SkDraw&, const void* text, size_t len, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { SkString pathID = fResourceBucket->addPath(); { AutoElement defs("defs", fWriter); AutoElement pathElement("path", fWriter); pathElement.addAttribute("id", pathID); pathElement.addPathAttributes(path); } { AutoElement textElement("text", fWriter); textElement.addTextAttributes(paint); if (matrix && !matrix->isIdentity()) { textElement.addAttribute("transform", svg_transform(*matrix)); } { AutoElement textPathElement("textPath", fWriter); textPathElement.addAttribute("xlink:href", SkStringPrintf("#%s", pathID.c_str())); if (paint.getTextAlign() != SkPaint::kLeft_Align) { SkASSERT(paint.getTextAlign() == SkPaint::kCenter_Align || paint.getTextAlign() == SkPaint::kRight_Align); textPathElement.addAttribute("startOffset", paint.getTextAlign() == SkPaint::kCenter_Align ? "50%" : "100%"); } SVGTextBuilder builder(text, len, paint, SkPoint::Make(0, 0), 0); textPathElement.addText(builder.text()); } } }
bool RenderSVGTextPath::stretchMethod() const { return textPathElement().method() == SVGTextPathMethodStretch; }
bool RenderSVGTextPath::exactAlignment() const { return textPathElement().spacing() == SVGTextPathSpacingExact; }
float RenderSVGTextPath::startOffset() const { return textPathElement().startOffset().valueAsPercentage(); }