Just in case anyone was wondering, at least I’m not the only one that is annoyed by fonts on Ubuntu .
As described by that bug report, the most annoying aspect of it is that different applications seem to behave differently. And other reports claim that settings change even if only have a blank .fonts.conf..
Anyhow, I think I’ve finally managed to cook something up that works pretty well.
The first thing to note is that, apps that render using the Xft library appear to have problems with the hintmedium hintsyle setting that Ubuntu defaults to. The most prominent of these apps in a standard Gnome-based Ubuntu desktop are Firefox and gnome-terminal (gnome-terminal uses Xft for performance reasons, apparently). Doing anything that causes these apps to try to render in the medium hinting style causes them to use the “slight” style instead, causing inconsistency among your apps.
The solution to this is to simply use “full” hinting for everything. That is accomplished by putting the following bit in your ~/.fonts.conf.

<match target="font">
<edit name="hintstyle">

This essentially means turn on “full hinting” for every font.
Now, that’s not really necessarily what you want. A case that commonly comes up for me is that I actually don’t want Japanese fonts to be hinted. But I choose to disable that selectively. I can do that with something like:

<match target="font">
<test name="family" qual="any">
<string>UmePlus P Gothic</string>
<edit name="hinting">

It has to follow the previous block (because the edits get evaluated in order).

DPI settings

The other part that causes major problems in font rendering is the screen DPI setting. There are numerous places that this value can be set, and having different values in different places causes different apps to render fonts in different ways.
The first thing to do is to make sure your settings are consistent. For my laptop, I decided that I wanted to use a DPI setting of 72. (It’s a 12 inch 1024×768). Here are the places I had to put this number in:

  1. In gnome-font-properties. Go in to the “details” screen and set the DPI to your desired value.
  2. In ~/.fonts.conf. Add the following bit:
    <match target="font">
    <edit name="dpi">

    This “edit” tag can be combined into the same “match” blog as the previous hintstyle setting if you prefer.

  3. Finally, the hardest one to find was for Firefox 2.0. Unfortunately, beginning in 2.0, Firefox no longer has a UI checkbox that determines whether the browser respects the system DPI setting when determining font sizes. Asside from this, the actual internal option that controls this value has changed three times from 1.0, to 1.5, and now 2.0. The magical value layout.css.dpi is described here. Set it to 72 using the the URL “about:config” in your browser

With these three settings, every app that I use regularly now has consistent font sizes and hinting settings.
I’m still not really sure why Ubuntu defaults to the “medium” hinting style, given the existence of these bugs. Maybe it was something introduced late in the cycle and nobody noticed.
Another interesting undocumented setting is MOZ_DISABLE_PANGO. This environment variable controls whether Firefox uses the pango module to render its text. It’s meaning is negative, so if you want pango rendering, you say MOZ_DISABLE_PANGO=0. On Ubuntu, this value is set in the firefox wrapper script depening on your locale, since pango is required to render some of the more complex scripts. It is not turned on by default, because there are some performance issues and it breaks MathML rendering (who cares). I also found that it has some minor text rendering bugs, but with pango, Firefox does seem to respect the gnome font properties’ hinting settings.
And a last note, if you do decide to use MOZ_DISABLE_PANGO=0, then make sure you set the layout.css.dpi value appropriately. For some reason, using pango makes the DPI calculation go really wonky. In my case every font was rendered much smaller than in other apps.

1 Comment

  1. javellan


    Thank you so much for that post. I’ve never seen my x60s look so amazing under feisty. Even more in love with my laptop and linux.

Leave a comment

Your email address will not be published. Required fields are marked *