Subject: Re: bug#77841: Some svg image's black color is replaced by emacs's theme foreground color

From: Manuel Giraud <[email-masked]>
Date: Sun, 04 May 2025 19:17:46 +0200

Alan Third <[email-masked]> writes:

> On Sat, May 03, 2025 at 03:39:22PM +0000, Ihor Radchenko wrote:
>> 
>> Alan Third <[email-masked]> writes:
>> > Does anyone know anything about "CurrentColor" in CSS? I'm wondering
>> > if that's our solution...
>> 
>> I do not know much, but from quick googling:
>> https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword
>
> As far as I an tell the attached patch works for anything that comes
> with Emacs itself. It may break any third-party SVG files used as
> widgets, or just relying on the fill colour being set. I don't think
> there's anything we can do about that if we want to change this
> behaviour.
>
> I don't know if anyone is actually using SVG files in that way, so
> this may not be a real concern. I'd still suggest we probably want to
> discuss this in Emacs devel to get it a little more visibility before
> pushing it.
>
> Needs documentation and news entry. But lets see if this actually
> works for everyone first.

Thanks Alan.  I've tested your patch and here is what I observe. What's
good:

       - SVG Emacs "widgets" are still using the default face color and
         are updating accordingly when changing theme

       - I use Gnus and I see the same behaviour for the SVG icon in the
         modeline

       - The german flag example provided by Billy is displayed
         correctly (filled with black where needed) whatever the theme
         in use

       - The example from Ihor shows 'x²=2' written in white on black
         whatever the theme in use

What's not so good:

I use DocView (with mupdf to generate SVG pages) and I have set
'doc-view-svg-face' to "inherit default" so that DocView buffers are
also following the theme.  This used to work but now, with this patch,
it does not render correctly.  For example, the text stays black instead
of white with a dark background theme.

Maybe, it is something that should be fixed in DocView (?)
-- 
Manuel Giraud