Converting svg to png while text wrapping using `shape-inside` text property

76 views Asked by At

I have an svg I made in Inkscape that uses the shape-inside text property to wrap text. When I output it to png using cairosvg, svglib, or wand the text bleeds off the image because shape-inside is not respected:

enter image description here

When I convert it to png using the Inkscape CLI the shape-inside is respected:

enter image description here

The text in the card is programmatically generated. The card text designer has no idea the width of the text area, and therefore cannot manually add newlines.

Currently, I call Inkscape using os.system("inkscape input.svg output.png"), but that means my python package depends on Inkscape being installed and installed in such a way that its available to the command line. Asking my users to install Inkscape is lame and will confuse many.

The shape-inside feature is in SVG 2.

My goals are:

  • Convert svg to png using only python (no calling programs that may not be installed)
  • Structure my svgs (using something such as shape-inside) so that it wraps text automatically, without baking cosmetic newlines into my card games rules
0

There are 0 answers