
Hello.
I need to get the geomtery of a text element. Please cosider the following code:
------------ <svg width="26in" height="16in" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect id="textbbox_2_check" x="5.3733333333333" y="11.31" width="15.773333333333" height="2.2966666666667" style="fill: none; stroke: #000000; stroke-width: 0.01" />
<text id="text_2_check" transform="translate(0,0)" style=" text-anchor:start; font-size: 1; font-family: Arial; fill: #000000; fill-opacity: 1; stroke: none;">Text Line 1</text>
</svg> ------------
As you can see, there is a simple text and a rect. What i need to do is "fit" the text inside that rect. To do this, i use this file (which is a temp file) to query width and height in order to obtain values to apply the correct scale transforms over it. The problem is that it seems texts are not parsed correctly at all. As far as i know, SVG user units should be 90 for 1 inch. So, doing [query-result]/90 gives me the inches value.
Here, the list of query commands performed on both text and rect elements. Below each command, i wrote 3 numbers: [query-result] - [query-result]/90 - inkscape (gui) shown inches value
inkscape -I "text_2_check" -W test.svg 419.81271 - 4.6645856666666666666666666666667 - 5.042
/usr/bin/inkscape -I "text_2_check" -H test.svg 87.39 - 0.971 - 0.730
/usr/bin/inkscape -I "textbbox_2_check" -W test.svg 1420.5 - 15.783333333333333333333333333333 - 15.783
/usr/bin/inkscape -I "textbbox_2_check" -H test.svg 207.6 - 2.3066666666666666666666666666667 - 2.307
As you can see, the "textbbox_2_check" values are correct, and query/gui values are equal. But "text_2_check" values are completely different... Why? Is there a way to get the correct width/height of a text element?
I really need this in order to make the correct "fitting" scaleratio, but i'm completely lost here. Can anyone help? Thanx in advance.
Alex