Bug 2405577 - emacs SVG rendering miscolors "fontcolor=black" compared to EOG (wayland + gtk)
Summary: emacs SVG rendering miscolors "fontcolor=black" compared to EOG (wayland + gtk)
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: emacs
Version: 42
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Peter Oliver
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-10-22 00:42 UTC by Martin Dengler
Modified: 2025-11-27 06:31 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-10-22 13:52:08 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Bug Tracker 73417 0 None None None 2025-10-22 13:52:07 UTC

Description Martin Dengler 2025-10-22 00:42:04 UTC
Something is wrong in emacs ("with support for Wayland, using the GTK toolkit") handling of "fontcolor=black", as can be seen with the attached screenshot.  The "fontcolor=black" is colored grey-ish, which seems to be some sort of default.  The EOG  (and google-chrome) rendering of the SVG is correct.

Reproducible: Always

Steps to Reproduce:
1. create testG2.dot
2. M-x graphviz-turn-on-live-preview
3. write this to testG2.dot buffer:

```
digraph G2 {
    node0 [label="default fontcolor"];
    node1 [label="this should be black\nvia fontcolor=black" fontcolor="black"];
    node2 [label="this should be black\nvia fontcolor=#000000" fontcolor="#000000"];
    node3 [label="this should be green" fontcolor="green"];
    node4 [label="this should be red" fontcolor="red"];
    node5 [label="this should be #FF0000" fontcolor="#FF0000"];
    node6 [label="this should be #000000" fontcolor="#000000"];
    node7 [label="this should be blue" fontcolor="blue"];
    node8 [label="this should be #0000FF" fontcolor="#0000FF"];

    node [fontcolor="black"];
    node9 [label="this should be black"];

    node [fontcolor="#000000"];
    node10 [label="this should be #000000\n(via node fontcolor default)"];

    node0 -> node1 -> node2 -> node3 -> node4 -> node5 -> node6 -> node7 -> node8 -> node9 -> node10;
}
```


Actual Results:
observe output (see http://xades.com/~martin/proj/bug-emacs-202251021/bugzilla-emacs-svg-render-screenshot-20251021.png )

Expected Results:
render colors correctly, like EOG (see http://xades.com/~martin/proj/bug-emacs-20251021/bugzilla-emacs-svg-render-screenshot-20251021.png )

Additional Information:
$ uname -a
Linux cdcx4 6.16.7-200.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 11 17:46:54 UTC 2025 x86_64 GNU/Linux
$ rpm -qi emacs
Name        : emacs
Epoch       : 1
Version     : 30.2
Release     : 1.fc42
Architecture: x86_64
Install Date: Wed 03 Sep 2025 12:16:40 AM EDT
Group       : Unspecified
Size        : 179346886
License     : GPL-3.0-or-later AND CC0-1.0
Signature   : RSA/SHA256, Mon 18 Aug 2025 12:41:10 PM EDT, Key ID c8ac4916105ef944
Source RPM  : emacs-30.2-1.fc42.src.rpm
Build Date  : Sun 17 Aug 2025 05:13:45 PM EDT
Build Host  : buildvm-x86-19.rdu3.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://www.gnu.org/software/emacs/
Bug URL     : https://bugz.fedoraproject.org/emacs
Summary     : GNU Emacs text editor
Description :
GNU Emacs is a powerful, customizable, self-documenting, modeless text
editor. It contains special code editing features, a scripting language
(elisp), and the capability to read mail, news, and more without leaving
the editor.

This package provides an emacs binary with support for Wayland, using the
GTK toolkit.
$

Comment 1 Martin Dengler 2025-10-22 00:46:00 UTC
Note: toggling between dark mode (which I had originally) and like mode in the GNOME Settings -> Appearance and restarting emacs does not change/fix the behavior.  I have not tried restarting Wayland / gdm in light mode, but will try that later and report if that changes the behavior.

Comment 2 Martin Dengler 2025-10-22 00:46:21 UTC
> toggling between dark mode (which I had originally) and like mode

*light mode

Comment 3 Martin Dengler 2025-10-22 12:09:35 UTC
Dark mode and light mode does not have an effect/fix on the problem.

Comment 4 Peter Oliver 2025-10-22 13:52:08 UTC
I think there are two issues happening in tandem, here:

- GraphViz discards the fill="black" attribute from text nodes when generating SVG (presumably because it thinks that black will always be the default, so it can save a few bytes by leaving it out).

- Emacs uses its own default text colour for text, even in SVGs.  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73417

I will make the case to the Emacs developers that image-mode should use a default text colour of black when rendering SVGs, because that’s what the SVG spec says (https://svgwg.org/svg2-draft/painting.html#FillProperty).

Meanwhile, a workaround for this issue would be to reset variable graphviz-dot-preview-extension to its default value of "png".

Comment 5 Peter Oliver 2025-11-25 15:18:03 UTC
This will be fixed in Emacs 31.

https://github.com/emacs-mirror/emacs/commit/2e3ee3e44803849b085a498fd4e64f84243e6c28

Comment 6 Martin Dengler 2025-11-27 06:31:04 UTC
Thanks very much!


Note You need to log in before you can comment on or make changes to this bug.