2012-01-26
The drawback of modern X font handling gets mysterious
Back in The drawback of modern X font handling I covered how modern X font rendering
happens in the client and so can vary from client to client, going
from nice on one client to bad on another. I illustrated this with
xterm
on Fedora and Ubuntu displaying the same font, Fedora well
and Ubuntu badly. I now have a good reason to change to using xterm
with modern fonts, so I spent part of today poking at this issue;
the results have turned this into a genuine peculiar mystery.
What I have so far:
- the problem does not happen with all programs on Ubuntu. So far
xterm
and GNU Emacs have the bad font rendering, but Firefox, gnome-terminal, and TK-based programs such asexmh
and tkmsg do not; they render DejaVu Sans Mono just like Fedora does. - the problem only happens with some monospace fonts, not all of
them. The Ubuntu machine I was testing on has 11 candidate
fonts listed by '
fc-list :scalable=true:spacing=mono: family
'; seven of them show the problem but four do not.(The good four are TlwgMono, Tlwg Typo, Courier New, and FreeMono. Unfortunately my preferred xterm font is DejaVu Sans Mono.)
- the problem is not the Ubuntu version of xterm, the Ubuntu app-defaults
file for xterm, or even the Ubuntu Freetype library; I have built
the Fedora xterm and my version of Freetype
on Ubuntu and used the Fedora app-defaults, and the bad rendering
is still there.
- I've directly set several fontconfig font rendering options that
might be doing this without changing anything; at this point I
haven't seen any difference with
autohint
,weight
,embolden
, oraspect
(the last was a wild shot). Similarly, Xft X resources (cf) do nothing that I can see.(Forcing
autohint=true
actually makes the Fedora font rendering slightly but visibly darker while leaving the Ubuntu rendering unchanged for both the good and bad programs.) - the problem doesn't happen with xterm on some FreeBSD machines I have handy; they render DejaVu Sans Mono the good way.
Clearly something mysterious is happening in the depths of the Ubuntu version of Xft or something it calls, but only if it's invoked in the right (or wrong) way. Unfortunately I don't think there's any good way for non-experts to see what font rendering choices are being made (the fontconfig library can be coaxed into some debugging output, but it's pretty much 'exports only' from what I can see), so I have no idea if I'll be able to figure out a solution that lets me use the font I want.
(Changing to gnome-terminal is not a solution for me.)