Subject: bug#51556: 29.0.50; Poor contrast of Customize SVG icons with dark backgrounds

From: Kévin Le Gouguec <[email-masked]>
Date: Mon, 01 Nov 2021 18:56:13 +0100

On darker themes (e.g. modus-vivendi), the Customize SVG icons
(etc/images/right.svg and etc/images/down.svg) are not very visible, due
to the poor contrast between their fill color (#2e3436) and dark
backgrounds[1].

Empirically, AFAICT, the "nuclear" solution of removing "fill:#2e3436"
from the SVG files causes the icons to render with the foreground color
of the default face.  That solves the contrast problem, but maybe a more
subtle solution could be devised?

Once the "fill:…" bit is removed, it becomes possible to change the SVG
image's color, either when calling create-image[2], or by applying
faces[3].

A quick dive into widget-create-child-and-convert (down to
widget-image-insert) suggests that there's no way to tell widget.el to
slap a face onto an image; perhaps a new keyword could be added to that
effect?

Then we could add a face that (1) could preserve the original color
(#2e3436) for light backgrounds (2) be set to something more reasonable
for dark backgrounds (3) be themed.

I wouldn't mind working on that (time permitting); I'd like to collect
some feedback first to make sure what I suggest is the right approach;
maybe there are better solutions I haven't considered.

Thanks for your time.

[1] https://webaim.org/resources/contrastchecker/?fcolor=2E3436&bcolor=000000

[2] E.g. after saving the attached rightnofill.svg, evaluate
    (insert-image (create-image "rightnofill.svg"
                                nil nil :foreground "orange"))

[3] E.g. after saving the attached rightnofill.svg, evaluate
    (insert-image (create-image "rightnofill.svg"))
    (add-text-properties (point-at-bol) (point-at-eol) '(font-lock-face success))

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0)
 of 2021-10-30 built on amdahl30
Repository revision: c30f95078c0735447c0bf293f2e6f573bc7057a3
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: openSUSE Tumbleweed

Configured using:
 'configure --with-cairo --with-gconf'

Configured features:
ACL CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix