Subject: bug#17792: 24.3; hintstyle spewcified via fontconfig is ignored by Emacs

From: Jan Djärv <[email-masked]>
Date: Sun, 22 Jun 2014 22:54:14 +0200

2014-06-18 06:44, Fangwen Yu skrev:
> Clearly the fontconfig version on my system understands hint setting. As I
> have said, if I have hintnone in fonts.conf and hintslight in X
> resources, Emacs will use hintslight and all other gtk applications like
> gedit, gnome-terminal will use hintnone.

It isn't about the fontconfig you have in the system when you run Emacs, it is about the fontconfig used to compile Emacs and libXft.

To repeat, Emacs only applies settings from GSettings, Xsettings and GConf.
fonts.conf and X resources are not read by any Emacs code, it is all done in library code.
So if you want to change something for Emacs, you must make sure it also gets changed in one of the places Emacs reads, which is not fonts.conf or X resources settings.

Gedit uses cairo, which in turn uses fontconfig and (possibly) libXft.
I don't know if cairo itself reads fonts.conf and/or X resources, but I suspect it does.
Emacs does not use cairo, so if there are differences, it is not surprising.

> 
> Since Emacs is also a gtk application, why doesn't it respect fontconfig settings?

Emacs is not a Gtk+ application in any sense of the word, it just uses part of its widget set in one of its configurations.  Emacs does not use rendering like Gtk+ programs do, it does not use the same configuration mechanisms either.
It also violates about every Gtk+ guideline for a good Gtk+ program...

   Jan D.

> 
> 
> On Tue, Jun 17, 2014 at 11:28 PM, Jan Djärv <[email-masked]
> <mailto:[email-masked]>> wrote:
> 
>    Hello.
> 
>    17 jun 2014 kl. 05:08 skrev [email-masked] <mailto:[email-masked]>:
> 
>     > I've noticed font rendering differences between Emacs and other gtk
>     > applications like gedit. In short, Emacs ignores hintstyle setting in
>     > fontconfig. I have hintstyle set to hintslight in
>     > ~/.config/fontconfig/fonts.conf, but I have to add 'Xft.hintstyle:
>     > hintslight' in Xresources to get the desired effect.
>     >
>     > The strange thing is that while ignoring hintstyle setting, Emacs still
>     > respect part of fontconfig settings, for example, anti-aliasing setting
>     > in fonts.conf will affect Emacs's font rendering.
>     >
> 
>    Hint setting is newer than the rest so it is possible your Emacs was
>    compiled against a fontconfig that don't have it.
>    Another possibility is that you have GSettings or GConf settings that are
>    different than fonts.conf or from the X resources.
> 
>    Emacs by itself does not read fonts.conf or apply X resources, it is all
>    done by fontconfig/Xft-libraries.  Emacs do apply GSettings and/or GConf
>    settings.
> 
>             Jan D.
> 
> 
>     > To be more precise, if I disable anti-aliasing in fonts.conf and enable
>     > it in Xresources, Emacs will not have anti-aliasing; if I have
>     > hintslight in fonts.conf and hintnone in Xresources, Emacs will use
>     > hintnone.
>     >
>     > I have tested with DejaVu Sans Mono 12 and Ubuntu Mono 13, but clearly
>     > it is not the fonts' problem.
>     >