The following happens to me on a regular basis when trying to write SVGs manually.
- I perform a web search for "svg drop shadow", and amongst the first hits is the MDN example on
feDropShadow, which feels a decent reference. - I copy/paste that example into a local
.svgfile. - When I look at this local
.svgwith various document viewers it shows as a blank white page -- not at all what the example is supposed to look like, and I'm very confused.
The source of the example looks like that:
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="shadow">
<feDropShadow dx="0.2" dy="0.4" stdDeviation="0.2" />
</filter>
<filter id="shadow2">
<feDropShadow dx="0" dy="0" stdDeviation="0.5" flood-color="cyan" />
</filter>
<filter id="shadow3">
<feDropShadow
dx="-0.8"
dy="-0.8"
stdDeviation="0"
flood-color="pink"
flood-opacity="0.5" />
</filter>
</defs>
<circle cx="5" cy="50%" r="4" style="fill:pink; filter:url(#shadow);" />
<circle cx="15" cy="50%" r="4" style="fill:pink; filter:url(#shadow2);" />
<circle cx="25" cy="50%" r="4" style="fill:pink; filter:url(#shadow3);" />
</svg>
and should look like this:
I'm a Linux user and the example renders as a blank white page in basically all my local tooling including:
- All my image viewers I tried including
eog(Ubuntu default image viewer) andgeeqie. - Inkspace
- ImageMagick's
convert
What adds to my confusion is that they don't render anything all, i.e., they seem to even ignore the "fill" as a result of feDropShadow being there. For instance, this is what I see in Inkscape (I've selected the elements to show that they are there in principle, just not rendering at all):
I can also use Inkscapes filter editor and remove the feDropShadow filters, which makes the elements appear again:
On the other hand the file does render correctly in any browser I tried. Also, the browser support matrix on MDN notes that most browsers have added support ~10 years ago, suggesting that it is not a brand new feature of the SVG standard.
I'm wondering why this is the case.
- Is there something unusual about the MDN example that could explain why it only works in browsers, or is it just a coincidence that all my local renderers simply don't support
feDropShadow? - Is it expected behavior that the renderers do to not show the elements at all if they don't support a certain filter, or is this yet another coincidence that they all end up showing a blank page?
(I couldn't identify the underlying rendering engine for all of them, so it also may come down to different tools simply using the same underlying renderer, but if I remember correctly at least Inkscape and ImageMagick have different renderers...)


