GNU bug report logs -
#77841
Some svg image's black color is replaced by emacs's theme foreground color
Previous Next
Full log
Message #116 received at 77841 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Alan Third <alan <at> idiocy.org> writes:
> On Fri, May 23, 2025 at 03:42:53PM +0200, Manuel Giraud wrote:
>> Alan Third <alan <at> idiocy.org> writes:
>>
>> > On 23 May 2025 12:19:15 BST, Manuel Giraud <manuel <at> ledu-giraud.fr> wrote:
>> >>Alan Third <alan <at> idiocy.org> writes:
>> >>
>> >>> On Fri, May 23, 2025 at 12:18:26PM +0200, Manuel Giraud wrote:
>> >>>> Hi Alan,
>> >>>>
>> >>>> Here is what I get:
>> >>>
>> >>> Thank you. That's what I see too. Are you able to send me an example
>> >>> SVG as generated by docview?
>> >>
>> >>Sure. Here is some book with light theme and a dark theme (pretty
>> >>unreadable ;-)
>> >
>> > Sorry, is it possible to get a copy of the actual SVG file, please?
>>
>> Here is an example from my docview cache.
>
> Clearly an excellent document.
😅
> OK, I'm pretty sure that the first patch that affects image.c is
> working right, which means my mediocre lisp skills are biting me here.
>
> Can you try running
>
> (concat "svg{fill:" (face-foreground 'doc-view-svg-face) "}")
>
> and see what it returns?
Just to be sure we're on the same page: I'm doing all those test on top
the patches you provided in this thread.
For both a light theme or a dark theme, I get "svg{fill:}".
> Although it's only just now occurred to me that I have no idea what
> face-foreground might return, presumably things that aren't CSS
> compatible?
>
> Hmm...
>
> Can you try replacing line 1680 in lisp/doc-view.el with
>
> :foreground (face-foreground 'doc-view-svg-face)
> :css "svg{fill:currentcolor;}")))
>
> I think that's the right number of brackets...
I was not sure so here is the patch I used:
[my.diff (text/x-patch, inline)]
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index d3e40e531f8..023409d800b 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -1677,7 +1677,8 @@ doc-view-insert-image
(setq args `(,@args :transform-smoothing t)))
(when (eq doc-view--image-type 'svg)
(setq args `(,@args :background ,(face-background 'doc-view-svg-face)
- :css ,(concat "svg{fill:" (face-foreground 'doc-view-svg-face) "}"))))
+ :foreground ,(face-foreground 'doc-view-svg-face)
+ :css ,(concat "svg{fill:currentcolor;}"))))
(apply #'create-image file doc-view--image-type nil args))))
(slice (doc-view-current-slice))
(img-width (and image (car (image-size image))))
[Message part 3 (text/plain, inline)]
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.
--
Manuel Giraud
This bug report was last modified 47 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.