Does anyone know how to attach a text to a path in Raphaël? Something like http://www.w3.org/TR/SVG11/images/text/toap02.svg
I know that jQuery SVG can do that, but I can’t find an easy way to do this by using Raphaël js. I want to attacht this text to a bezier curve and move it.
Does anyone know how to attach a text to a path in Raphaël? Something
Share
There are 2 ways to do this.
The easier way is to make use of the Raphael
.print()method. This can turn text into paths. Each character gets its own path. Then you can iterate over each character and move and rotate it appropriately using.translate()and.angle().The harder way is to implement text on path for both SVG and VML for a Raphael
.text().Here’s a quick and rough start for Method 1 with no rotation using
.print()and this font:Try it out with this jsFiddle
Note: The above code is very rough and has some important positioning problems, but I think the general approach is the way to go for putting text on a path with Raphael.