How to use SVG DOM in Python

This question may seem silly, but I can't find the right answer myself. I am trying to use the SVG DOM interface in my python script. I would like to use getComputedTextLength , but I cannot find it, even if I thought at first that it would be available thanks to a module or packages like python-svg or something like that. I'm sure something is missing, but I can’t find what.

Any help would be greatly appreciated. Thanks.

EDIT: I forgot to talk about what my script does. This is a Python script used to generate an SVG file from data captured on the Internet. My script should write texts and repeat them along the way. In addition, since I know the exact length (in pixels) of the path, I need to know the length of the text in order to repeat only what I need. This is why the getComputedTextLength method is useful.

+6
source share
2 answers
+2
source

I do not think that's possible. The DOM is one thing, and calling a browser function is another. I just saw a Python module that helps you create tree structures such as HTML or SVG, but they do not provide any other additional functions. (By the way, the last time I look, browsers had problems with getComputedTextLength correctly calculated, but that was some time ago ...)

You can try a better job with fonttools .

0
source

Source: https://habr.com/ru/post/892171/


All Articles