Beautiful Font Hinting in Ubuntu 8.10 and 9.04

Even though I have an LCD monitor, I always have the subpixel hinting switched off because it is just painfully ugly to my eyes. Even when hinting is switched to maximum, the fonts are quite blurry (if you don’t believe me, type xmag and take a screenshot of your font. You can see red and blue linese everywhere). My eyes hurt when I see this.

Thanks to Johan Kivinemi I have just found out how to bring back the excellent legacy subpixel hinting engine. This has a much more crisp hinting, and uses subpixels only where it really is an improvement:

Just open these files in your home directory, and copy the content into them:

~/.fonts.conf

[sourcecode lang="xml"]





true


true


hintfull


lcdlegacy


rgb



[/sourcecode]

~/.Xresources

[sourcecode lang="xml"]
Xft.antialias: true
Xft.hinting: true
Xft.hintstyle: hintfull
Xft.lcdfilter: lcdlegacy
Xft.rgba: rgb
[/sourcecode]

This should work in Ubuntu 8.04, 8.10, and 9.04 too, and makes all fonts much more crisp. Of course, your mileage may vary.

UPDATE: Comparison Screenshots

As promised on reddit, I got back from an awesome snowboard trip so I am able to put up extensive comparison screenshots of the two subpixel hinting engines. Move your mouse over the following images to see the differences. Watch especially out for letters like “m” where the spacing between the lines is very small. You might have to wait a bit for the image to load.

I have used all of the most important fonts that I usually use, and just for fun I have added “Dijkstra”, which just looks cool.

Sans Fonts

Mouse to see the same fonts with the legacy hinter.

 

Mono Fonts

Mouse to see the same fonts with the legacy hinter.

 

Zoomed Comparison Screenhots

Here is an excerpt with 400% magnifications. Mouse over the pictures to see the legacy hinter.

Zoomed Sans

 

Zoomed Mono

 

29 thoughts on “Beautiful Font Hinting in Ubuntu 8.10 and 9.04”

  1. ochs,

    Translucent pixels or subpixels where they aren’t needed mean blurry text. Subpixel rendering or not, horizontal and vertical lines should only consist of 100% transparent and 100% opaque (sub)pixels.

  2. Look at the “x” in Verdana 11; it has faded lines which only get worse when you mouse over it . . . The fix helps in many cases, but I have noticed some instances on particular letters such as “k”, “x”, etc., where the diagonal lines actually fade worse when using the improved rendering scheme . . . ? The problem seems to varie tremendously depending on the font size and font type.

  3. Hi krt, you are right it really looks as if the x is fading. I think it looks a bit better with the default renderer because it is more bold in general. I think the x looks so bad because the hinting information is not very good for this font size, so the font designer could have done a better job.

  4. While lcdlegacy may make the fonts less blurry, the settings also makes the font “tingle” in a visual way. I have problem with it because to me the lcdlegacy setting makes the rgb subpixel hinting a lot more visible, with all sorts of weird colours appearing at the edges of fonts. This isn’t the case when I have it set to lcddefault. I’m using an LCD screen btw.

    Another question: is there a way to force grayscale smoothing instead of rgb smoothing in .fonts.conf or .Xresources? I already googled for it some hours, but nothing ever shows up.

  5. Happy (or shall I say disappointed) to say these tricks still work (and are required) in 9.04.

    Thanks! I’m beginning to think some of the Ubuntu developers are typography blind.

  6. By the way, KDE doesn’t like the above .fonts.conf file format, it wants all the edit-tags separately between their own match-tags, like this:

    true

    true

    and so on.

    I don’t know why KDE is nitpicking on this. The example file works if you don’t touch anything, but if you experiment with KDE Control Center font settings, the file gets overwritten if it isn’t already in the correct format. So, could you please ‘fix’ the example .fonts.conf file so it works with KDE without trouble?

  7. Argh, the system tried to interpret the XML tags… Here’s an example without the arrows

    match target=”font”
    edit name=”antialias” mode=”assign”
    bool true /bool
    /edit
    /match
    match target=”font”
    edit name=”hinting” mode=”assign”
    bool true /bool
    /edit
    /match

  8. Thank you so much Martin for the past couple of days I have been straining my eyes trying to figure out how to fix my font. Everything was red green and blue. Ubuntu must have change something, or maybe it was my new Nvidia GTX 285 card. I’ve never had a problem like this before, fonts have always been super crisp on Ubuntu. Thanks a bunch.

    Oh by the way I had a little trouble copying the code you had in this article. I had to go back and delete all the line numbers down the left side. You might want to change that especially if you post really long code on your site. It could be problematic in cases like that.

  9. Hi John, to copy the code to the clipboard click on “copy to clipboard” :-)
    Or, if this does not work, click “view plain” and copy the content from the popup window.

  10. Thanks for your help, Martin. Your files worked for me with Ubuntu 9.04, but they don’t work in Ubuntu 9.10. I changed “lcdlegacy” to “lcdnone” in both files in Ubuntu 9.10, and now the font rendering seems to look like it did in Ubuntu 9.04 after I used your files.

  11. Thanks a lot for the info. Just that it stops working after u/g to 9.10. Some how it’s always set to lcddefault when checked with “xrdb -query”. Would be great if this can be fixed.

  12. I had a feeling that my fonts in Ubuntu 10.10 are broken on my laptop. Your solution works greatly on my Ubuntu 10.10 . Thank YOU.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>