I use python to generate an SVG with text that can change, and I would like to place a translucent rectangle behind it to guarantee some contrast when it overlays another graphic element later.
Unfortunately, I don't know how to predict the pixel extents of a particular line of text in SVG. I can choose which font I use (but I donβt think that a mono error will be acceptable) and what font size I use.
How can I use python to predict the extents of SVG text so that I can create a rectangle of the appropriate size?
source
share