How to position text by bounding box

Asked by Dan on 2008-02-20

Hello,

SVG specifies that the x,y position for text elements is the alignment point (intersection of baseline and leftmost glyph point). This point seems to vary (relative to the text's bounding box) by font and even by the letters used.

I need to set the svg x, y values based on the bounding box from outside of Inkscape, using a script. I see no simple way to determine a mapping from the alignment point to a bounding box feature. This seems like an oversight in the SVG spec.

So, I have the following ideas:

- Extend the Inkscape command line to include a "query bounding box" parameter for text elements. This (together w/ the "queryx" feature) would allow me to calculate a mapping between them in my script.

- Extend Inkscape to allow for a "boundingx, boundingy" attribute on the text element (I don't like this at all, as it screws w/ the spec impl.)

And now my question(s):

- Am I missing an easy way to accomplish this?
- Is there a better way to extend Inkscape? (I am considering doing it myself).

Thanks,

Dan

Question information

Language:
English Edit question
Status:
Answered
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Last query:
2008-02-20
Last reply:
2008-02-29
Krzysztof Kosinski (tweenk) said : #1

I tested with 0.46-pre2 and it seems to me that --query-x, --query-y, --query-width and --query-height retrieve the bounding box dimensions of text and tspan elements. If you want to determine the alignment point, that might be trickier - you will need to parse the SVG yourself.

Can you help with this problem?

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

To post a message you must log in.