rsvg-convert : priority of style elements (possibly) doesn't match documentation
Issue Summary
The manpage for rsvg-convert documents the --stylesheet option and says that styles in the extra sheet override the document. It gives an example which does work correctly. However if the styles are given in a <style>
element within the SVG file, these are not overridden by the extra stylesheet.
I may have misunderstood the docs or the way stylesheets work in SVG, please let me know.
Example SVG input.svg
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<style type="text/css">
.recolorable { fill: red }
text { font-family: sans-serif; font-size: 20}
</style>
<rect width="200" height="100" fill="white" />
<rect class="recolorable" x="10" y="10" width="50" height="50" />
<text x="10" y="80" fill="currentColor">Hello</text>
</svg>
Example CSS extra-styles.css
.recolorable {
fill: blue;
}
* {
color: green;
}
Command line
rsvg-convert input.svg -o output1.png
rsvg-convert --stylesheet=extra-styles.css input.svg -o output2.png
Expected that, in output2.png, the stylesheet would override the fill colour of the rectangle. I actually see the rectangle stays red but the text is coloured green (presumably because that's not specified in input.svg)
Librsvg Version
rsvg-convert version 2.54.5
Platform
WSL (Debian)
Additional logs
RSVG_LOG=1 rsvg-convert --stylesheet=extra-styles.css input.svg -o output.png
does not produce any output.