Subject: bug#25147: 25.1; rgba font rendering not honoring fontconfig

From: Yuri D'Elia <[email-masked]>
Date: Fri, 09 Dec 2016 16:56:36 +0100

On emacs 25.1.1 and emacs 24.5.1 (lucid, from debian unstable) all font
rendering settings (hinting/antialias/autohint/etc) seems to correctly
come from fontconfig, with the exception of the "rgba" setting (subpixel
hinting), which just defaults to disabled.

The Xft.rgba X resource *does* have effect though.

Emacs should honor the fontconfig's rgba setting correctly, with
priority over Xft.* resources, as done for the other settings.

To test, remove any X resource (xrdb -remove), and install the following
fontconfig snippet somewhere in ~/.config/fontconfig/conf.d:

<?xml version="1.0"?>
<fontconfig>
  <match target="font">
    <edit name="hinting" mode="assign">
      <bool>true</bool>
    </edit>
    <edit name="rgba" mode="assign">
      <const>rgb</const>
    </edit>
  </match>
</fontconfig>

Run emacs, and notice how subpixel hinting is not enabled.
Run with FC_DEBUG=5 set in the env for confirmation that the rgba=rgb is
in effect.

Then run emacs -xrm 'Xft.rgba:rgb' and notice the difference (color
fringing should be visible).

extra info:

In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2016-12-01, modified by Debian built on trouble
Windowing system distributor 'The X.Org Foundation', version 11.0.11900000
System Description:	Debian GNU/Linux unstable (sid)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --with-x=yes --with-x-toolkit=lucid
 --with-toolkit-scroll-bars --without-gconf --without-gsettings
 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs25-Fs4LPA/emacs25-25.1+1=.
 -fstack-protector-strong -Wformat -Werror=format-security -Wall'
 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11

Important settings:
  value of $LC_COLLATE: C
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix