From e15a0fb2ed961b5c821af67d1c29d9d826bc1eaa Mon Sep 17 00:00:00 2001 From: Jonathan Siegel Date: Fri, 31 Aug 2012 19:55:50 -0700 Subject: [PATCH 1/2] Added Textpath attributes in Text support --- svg.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/svg.go b/svg.go index ab68939..ff92464 100644 --- a/svg.go +++ b/svg.go @@ -339,6 +339,24 @@ func (svg *SVG) Text(x int, y int, t string, s ...string) { svg.println(``) } +// Adding Text begin/end for better Textpath control +// Without this could not set a startOffset=XX% in Textpath block +/* Usage: + svg.Path("M250 250 L 400,250", `id="poly1"`, `stroke="red"`, "stroke-dasharray: 5") + svg.TextBegin(`fill="black"`, `text-anchor="middle"`, `font-size="6pt"`) + svg.Textpath("This is Centered!", "#poly1", `startOffset="50%"`) + svg.TextEnd() +*/ +func (svg *SVG) TextBegin(s ...string) { svg.println(`")) } +func (svg *SVG) TextEnd() { svg.println(``) } +func (svg *SVG) TextpathInner(t string, pathid string, s ...string) { + svg.printf(""), pathid) + xml.Escape(svg.Writer, []byte(t)) + svg.println(``) +} + + + // Textpath places text optionally styled text along a previously defined path // Standard Reference: http://www.w3.org/TR/SVG11/text.html#TextPathElement func (svg *SVG) Textpath(t string, pathid string, s ...string) { From aa4d31f9a654b7bea57f6746637a9266569f0b5c Mon Sep 17 00:00:00 2001 From: Jonathan Siegel Date: Fri, 31 Aug 2012 19:59:36 -0700 Subject: [PATCH 2/2] Fixed implementation errors. --- svg.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svg.go b/svg.go index ff92464..4852288 100644 --- a/svg.go +++ b/svg.go @@ -347,10 +347,10 @@ func (svg *SVG) Text(x int, y int, t string, s ...string) { svg.Textpath("This is Centered!", "#poly1", `startOffset="50%"`) svg.TextEnd() */ -func (svg *SVG) TextBegin(s ...string) { svg.println(`")) } +func (svg *SVG) TextBegin(s ...string) { svg.printf(`")) } func (svg *SVG) TextEnd() { svg.println(``) } func (svg *SVG) TextpathInner(t string, pathid string, s ...string) { - svg.printf(""), pathid) + svg.printf("")) xml.Escape(svg.Writer, []byte(t)) svg.println(``) }