SVG: Manipulation with text length and size

Adry
09-01-2005, 04:48 AM
Hallo all,

I'd like to do in SVG the following: to draw a rectangle with the text inside such that, if the length of the text (in pixels) is longer than rectangle width, then the text should be adjusted to the width of rectangle. If the text can be put inside a rectangle without any changes, adjusting is not needed.
Also the font size of the text should be somehow related to the size of the rectangle (which is given relatively, in percents, like <rect width="3%" height="2%" />). But it doesn't work, if one writes e.g. font-size="1%"...

As for text adjusting, if I use the textLength attribute (i.e. set it equal to rectangle width), then the text will be _always_ adjusted to the rectangle width, even if there is enough space for the text in initial state, what would be not so wished...

As one can see, textLength atribute can not be used as well as relative text size (in %) doesn't work. What can I do in such a case? The only solution as I see is usage of JavaScript and calculation of text size and adjusting already on the client side... But it would not be very well, may be there are another approaches to the problem?

Many thanks in advance.[/code]

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum