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

From: Alan Third <[email-masked]>
Date: Sun, 25 May 2025 14:02:20 +0100

On Sun, May 25, 2025 at 09:19:53AM +0300, Eli Zaretskii wrote:
> > Date: Sat, 24 May 2025 21:56:59 +0100
> > From: Alan Third <[email-masked]>
> > Cc: Ihor Radchenko <[email-masked]>,
> > 	Billy Lei <[email-masked]>, Eli Zaretskii <[email-masked]>,
> > 	[email-masked]
> > 
> > On Sat, May 24, 2025 at 07:57:26PM +0200, Manuel Giraud wrote:
> > > With this and the same SVG I provided, the foreground color of the text
> > > is black using a light theme.  Using a dark theme, the foreground color
> > > of the text is white...  So that seems to do the trick.
> > 
> > Excellent, thanks.
> > 
> > I've pushed a branch scratch/svg-colors with the various fixes. Can
> > you please check it's working as you'd expect?
> > 
> > Can someone using librsvg < 1.48 please try it too? I'm including a
> > small script that should insert an SVG with two boxes, one follows the
> > theme colours the other stays with black and white.
> > 
> > If this all works then I suppose the documentation needs updated...
> 
> What needs to be updated in the documentation?  I thought this was
> about fixing a bug, not changing behavior.  What did I miss?

I'm trying something slightly different to see if it makes people
happier.

Instead of over-riding the default fill colour we'll set the
"currentcolor" to our foreground colour. This appears to be how web
browsers handle this.

Basically, this means the default foreground colour remains black, but
by setting "fill: currentcolor" in the SVG the foreground colour will
be set to Emacs's foreground colour.

Setting the image's :css parameter to

    svg {
      fill: currentcolor;
    }

will give the same behaviour as we have at the moment.

I'm not sure if this is actually a better approach, but it seems to
align more closely with how SVG's are usually used, so might cause
less confusion.

-- 
Alan Third