I\'m creating an SVG text box using the Raphael library, and filling it with a dynamic string which is extracted from an XML document.
Sometimes, this string is long
Well, i solved it tweaking it a little bit
var words = server.split( " " );
var length = words.length;
var temp_text = "";
for( var i = 0; i < length; i++ ) {
temp_text = temp_text + ' ' + words[i];
t.attr( "text", temp_text );
if( t.getBBox().width > width ) {
temp_text = temp_text.replace(/( *)(\w+)$/, "\n$2");
}
}
t.attr( "text", temp_text.trim() );