bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alan Third
Subject: bug#77841: Some svg image's black color is replaced by emacs's theme foreground color
Date: Wed, 16 Apr 2025 17:22:41 +0100

On Wed, Apr 16, 2025 at 03:55:08PM +0300, Eli Zaretskii wrote:
> > Date: Wed, 16 Apr 2025 20:09:46 +0800
> > From: Billy Lei <LeiYiXia29@outlook.com>
> > 
> > I found this issue when debugging org LaTeX preview, see 
> > https://list.orgmode.org/87cydchjqn.fsf@gmail.com/T/#ed7ba8310f82e8be8a2e7360df1568ed485434df3
> > 
> > > When using themes with background color set to #000000, and 
> > > org-preview-default-process is set to dvisvgm, the LaTeX fragments are 
> > > displayed incorrectly.
> > > 
> > > To reduplicate:
> > > 
> > > 1. Switch to a theme with background color set to #000000 (like Modus 
> > > Vivendi)
> > > 2. Set org-preview-default-latex-process to dvisvgm
> > > 3. Create an org-mode document. Write some LaTeX fragment and press C-c 
> > > C-x C-l to preview LaTeX fragment.
> > > 4. The LaTeX preview is displayed as a white rectangle.
> > > 
> > > After debugging, I found that it is because dvisvgm omitts the default 
> > > #000 color value when generating SVG file, and emacs has a unique way of 
> > > displaying the SVG, which caused foreground color to be applied to it.
> > > 
> > > A solution is to change org-format-latex-options to use transparent 
> > > background by default. I've attached this fix.
> > 
> > It turned out that emacs displays svg images differently compared to an 
> > image viewer. I can reduplicate this issue when I use emacs to view this 
> > svg image, which emacs replaces the image's black color with the current 
> > theme's foreground color:
> > 
> > https://commons.wikimedia.org/wiki/File:Flag_of_the_German_Democratic_Republic.svg
> > 
> > See also (Chinese): https://emacs-china.org/t/emacs-30-1-svg/29217
> 
> Yes, this is a feature.  I think to disable it, you need to include a
> :background setting in the image spec.  Alan, am I right?

Yes, but in this particular case :foreground, probably.

This behaviour is documented in the elisp manual under "SVG Images"
and is intended to make it easier to insert images into buffers so
they look like native widgets and the like.

We only set the default foreground and background colours, we don't
override explicitly set colours. The easiest work-around for someone
generating an SVG for display in Emacs is to just not set foreground
and background colours at all, and then they'll both match the current
theme (and also work correctly in web browsers).

(IMHO if an SVG needs a specific colour, like the black in the German
flag above, it should be setting the colour explicitly, rather than
relying on the image viewer's default settings.)
-- 
Alan Third





reply via email to

[Prev in Thread] Current Thread [Next in Thread]