How to either determine SVG text box width, or force line breaks after 'x' characters?

There isn't an attribute for text wrapping, but there is a simple trick you can use. Add one word at a time to a text object and when it gets too wide, add a line feed. You can use the getBBox() function to determine the width.

Basically, you emulate an old fashioned typewriter. Here is a sample of some code that will do this for you. You could easily turn this into a simple function that takes the text and a width.

There isn't an attribute for text wrapping, but there is a simple trick you can use. Add one word at a time to a text object and when it gets too wide, add a line feed. You can use the getBBox() function to determine the width.

Basically, you emulate an old fashioned typewriter. Here is a sample of some code that will do this for you. You could easily turn this into a simple function that takes the text and a width.

Var r = Raphael(500, 500); var t = r. Text(100, 100). Attr('text-anchor', 'start'); var maxWidth = 100; var content = "Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam.

Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh.

Donec suscipit eros. Nam mi. Proin viverra leo ut odio.

Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. "; var words = content.

Split(" "); var tempText = ""; for (var i=0; I maxWidth) { tempText += "\n" + wordsi; } else { tempText += " " + wordsi; } } t. Attr("text", tempText. Substring(1)).

Thnx mate you saved the day! – chchrist Nov 11 at 13:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions