Open joachimheintz opened 1 year ago
Thanks so much for all these examples. I've actually never used these attributes before but they appear to be part of the SVG 2 specification that CairoSVG doesn't really support. Yes, I would definitely support the addition of alternate rendering backends, especially given the limitations of CairoSVG.
I think it would be useful to add an option to Drawing.rasterize
and Drawing.save_png
and possibly also have a global default backend similar to matplotlib. Here's some code I've previously written to call out to inkscape:
resvg looks like a great project. I'll need to try it out sometime. Have you had good results with it? If it works well, I might try packaging it into a Python wheel for easy use with drawsvg.
Here are two relevant methods where new backends would be added: Raster.from_svg()
and Raster.from_svg_to_file()
there are some important features of svg text rendering which do not work in the internal jupyter notebook view, but do work when i export an svg file and then render the file with inkscape.
below are examples for some of these important differences. my question is: can text rendering in drawsvg be improved? or can the inkscape svg renderer be added as alternative? (cairosvg which is used by drawsvg states about itself: "Text and features related to fonts are poorly supported" --- which is true unfortunately.)
auto-wrapped text with 'inline-size' property (see W3C)
this is the code:
this is the file which is rendered by drawsvg as png (with the same output as in the jupyter notebook):
this is the file which is rendered by inkscape:
![auto-wrapped-inkscape](https://github.com/cduck/drawsvg/assets/2196394/50055a11-d403-4d7b-bb97-39b33019a469)
the 'shape-inside' property (see W3C)
view in the notebook and in the exported png:
rendered by inkscape:
![shape-inside-inkscape](https://github.com/cduck/drawsvg/assets/2196394/9261f849-89f6-471e-9d47-81243123794f)
white space
white space can be preserved with the
white__space='pre'
property (see W3C for all options).rendered in drawsvg:
rendered with command-line inkscape:
![white-space-inkscape](https://github.com/cduck/drawsvg/assets/2196394/abb74b83-9329-4b55-9058-f5b7cc843a07)
result / question
cairosvg which is used by drawsvg is really missing important features of svg text. is it possible to allow other rendering options? for my case, inkscape is good because it can also render to pdf. for other cases, resvg may also be an option.
my configuration: debian 11, Inkscape 1.2.2 (b0a8486541, 2022-12-01)