[cairo] Output SVG with fill and alpha stroke, but without inline images ?

Uli Schlachter psychon at znc.in
Thu Mar 25 16:06:36 UTC 2021


Am 24.03.21 um 02:22 schrieb Stuart Axon:
> I've been trying to generate an SVG using SVGSurface with a fill and an alpha stroke, 
> with OPERATOR_SOURCE to ensure the stroke draws over the fill, but this seemsto generate <image> tags in the SVG.
> Toy example and output + XML:
> https://gist.github.com/stuaxo/b525a47d33f5f3074b1be7c693f6b6e6
> Is there any way to render fill + stroke (with alpha) and only output vector data ?This seems like a common operation, but whatever I try outputs SVGs full of <image>s.
> For Shoebot, this has meant our SVGs become very very large, enough to eat all your ram if you try and open them in Inkscape.

I ported your example code to C (attached). Don't ask me why, but I
experimented with the SVG version. And it helped!

More specifically, adding this line:

  cairo_svg_surface_restrict_to_version(s, CAIRO_SVG_VERSION_1_2);

...causes a small difference in the output with/without operator SOURCE:
The path's style gets a new "comp-op:src;clip-to-self:true" entry.
Everything else stays the same (well, except the header saying
version="1.2" instead of the previous version="1.1").

So, I do not really have much clue about SVG, but I guess this means that:
- cairo defaults to SVG 1.1
- SVG 1.1 does not support operator SOURCE

Homophobia - The fear that another man will treat you the way you treat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 644 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20210325/d53011cb/attachment.c>

More information about the cairo mailing list