Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize text in svg dynamically?

I'm working on a report that includes an embedded svg diagram. The diagram is drawn using relative coordinates, so when a browser window resizes the diagram resizes pretty well. The only exception there is text - it remains the same. Is it possible to draw text in svg that is resizable?

like image 221
Niccolo Avatar asked Nov 05 '22 22:11

Niccolo


1 Answers

I think you have to use a relative size for the font-size. See http://www.w3.org/TR/SVG11/coords.html#UnitIdentifiers. When you use an absolute size like pt or cm, it is automatically calculated what the size must be to display correctly on your monitor, to get that size. But when you use px, the current viewport is used. If you don't specify a unit, the user units are also used as in the example on the linked document:

<text style="font-size: 50">Text size is 50 user units</text>
like image 60
wimh Avatar answered Dec 25 '22 11:12

wimh