how to get text width in pt from command line using -query

Asked by Ciprian

I have a svg file that have a text line like in bellow svg example.
I need to change in that svg line text with other and that text need to be horizontally centered.
For example I have original svg like:
<svg width="480pt" height="250pt" viewBox="0 0 480 250" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text style="fill:rgb(153,31,47)" font-family="Futura Md BT" font-size="27" transform="matrix(1,0,0,1,0,154.85)" id="fls_line_0"><![CDATA[Original Text]]></text>
</svg>

Using php I will edit svg changing text value. After that I will use inkscape command line (linux) to get x, y, width of that line text. I get that width and I do a simple math: x = (480-text_with)/2
I will use x value to replace matrix from matrix(1,0,0,1,0,154.85) to matrix(1,0,0,1,x,154.85)
Because query return results in px, when I create a png from new svg (command line) text actually is not centered.

It's possible -query to return data (x,y,width,height) in pt?

Question information

Language:
English Edit question
Status:
Answered
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
mahfiaz (mahfiaz) said :
#1

You could do the unit conversion yourself. From http://wiki.inkscape.org/wiki/index.php/Release_notes/0.41 :

Note however that the conversion ration from px to absolute length units may vary in different SVG renderers and different output media (e.g. Inkscape uses px/pt = 0.8)

Can you help with this problem?

Provide an answer of your own, or ask Ciprian for more information if necessary.

To post a message you must log in.