GNU bug report logs - #77841
Some svg image's black color is replaced by emacs's theme foreground color

Previous Next

Package: emacs;

Reported by: Billy Lei <LeiYiXia29 <at> outlook.com>

Date: Wed, 16 Apr 2025 12:16:02 UTC

Severity: normal

Full log


Message #125 received at 77841 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: yantar92 <at> posteo.net, 77841 <at> debbugs.gnu.org, manuel <at> ledu-giraud.fr,
 LeiYiXia29 <at> outlook.com
Subject: Re: bug#77841: Some svg image's black color is replaced by emacs's
 theme foreground color
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 <alan <at> idiocy.org>
> > Cc: Ihor Radchenko <yantar92 <at> posteo.net>,
> > 	Billy Lei <LeiYiXia29 <at> outlook.com>, Eli Zaretskii <eliz <at> gnu.org>,
> > 	77841 <at> debbugs.gnu.org
> > 
> > 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




This bug report was last modified 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.