How to limit svg text width in all browsers

Discuss SVG code, accessible via the XML Editor.
Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

How to limit svg text width in all browsers

Postby Vectorator » Sat Mar 14, 2015 7:17 pm

I have a conundrum which might derail my entire svg project :(

I have spent a few days redesigning my header completely in svg code.

I have text overlaying a rectangle (the rectangle is a certain width).

But how can I get the text to be the same width in all browsers and all fonts?
I tried using the textLength but I got a different result in firefox vs ie or Safari.

Of course if it was html I would just put the text inside the rectangle, but I can't with svg as far as I know.

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: How to limit svg text width in all browsers

Postby Vectorator » Sat Mar 14, 2015 7:23 pm

Nevermind, I worked out an acceptable solution to this.

I was using <text> with <tspan>'s including spaces.
When I just used two <text>'s without <tspans> it works well enough with different fonts to be good enough.


Return to “SVG / XML Code”