Bad font anti-aliasing in Ubuntu

36

31

I'm switching from Fedora 8 to Ubuntu 9.04, and I can't seem to get it to get a good font anti-aliasing to work. It seems that Ubuntu's fontconfig tries to keep characters in integral pixel widths. This makes text more difficult to read, when 1 pixel is too thin and 2 pixels is too thick.

Check the image below. In Fedora, when fontconfig anti-aliasing is enabled, fonts have their thickness proportional to the font size. Below, the thickness is different for 8, 9 and 10pt sizes. In Ubuntu, on the other hand, even when anti-aliasing is enabled, all 8, 9 and 10pt sizes have 1 pixel thickness. This makes reading larges amount of text difficult.

Comparing Fedora 8 and Ubuntu 9.04 font anti-aliasing.

I'm using the very same home directory, and I already checked that X resources are the same in both systems:

~% xrdb -query | grep Xft
Xft.antialias:  1
Xft.dpi:        96
Xft.hinting:    1
Xft.hintstyle:  hintfull
Xft.rgba:       none

GNOME settings:

~% gconftool-2 -a /desktop/gnome/font_rendering
 antialiasing = grayscale
 hinting = full
 dpi = 96
 rgba_order = rgb

So, the question is: What should I change in the new box (Ubuntu) in order to get anti-aliasing like in the old box (Fedora)?

Juliano

Posted 2009-07-19T23:22:23.070

Reputation: 2 492

8Is it just me who thinks that the Ubuntu fonts are much sharper and readable than the Fedora fonts? The Fedora fonts look way too blurry IMHO. – Yaba – 2010-08-12T10:02:54.373

I actually like the one on the right more. The one on the left is way too blurry. To each his own, though. ;) – Sasha Chedygov – 2010-08-12T10:03:11.977

@Yaba: Obviously not... You beat me by 17 seconds. :) – Sasha Chedygov – 2010-08-12T10:04:01.327

1@Yaba, @musicfreak: If you have CRT monitors or have a low resolution, the ones on the left may look too blurry. Otherwise, they better reflect the size of the font. Look at how the thickness of the lines in the right image suddenly jump from 1px to 3px as you increase the font size. This is also bad when it is being projected. The text doesn't become more readable as you increase the font size until it is too big (when it jumps to 3px). – Juliano – 2010-08-12T13:44:43.813

1Also, in the Ubuntu sample, look at how there is a missing pixel in the "k" in "quick" in the third text line, making it look like it was two glyphs, a "|" and a "<". – Juliano – 2010-08-12T13:49:02.853

2@Juliano

Then I have the first available Laptop with a built in CRT monitor :-) – Yaba – 2010-08-20T17:24:37.757

Answers

36

There is an old trick to make fonts smoother on Ubuntu (and pretty much every distro running Gnome):

Open up .fonts.conf under your home directory (~/.fonts.conf) and paste this in:

<?xml version="1.0" ?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
   <fontconfig>
      <match target="font">
         <edit name="autohint" mode="assign">
            <bool>true</bool>
         </edit>
      </match>
</fontconfig>

Before:

alt text

After:

alt text

John T

Posted 2009-07-19T23:22:23.070

Reputation: 149 037

3Sad reflection on the GNOME philosophy that you even have to ask this question. – sml – 2010-07-20T18:59:06.893

I'm using gnome on Debian 8 and doing this + restarting worked for me too. Thanks! – bzim – 2017-03-18T15:28:45.743

2+1. Insane that this isn't surfaced in the font preferences in some way. – Kent Boogaart – 2009-08-17T19:11:03.350

@Juliano Auto-hinting works correctly with sub-pixel rendering, so there is no need for rgba=none. – Adam Byrtek – 2011-05-30T19:20:19.887

@Adam: Are you talking about now or about when this question was asked, back in 2009 (Ubuntu 9.04)? – Juliano – 2011-05-31T01:04:51.067

Now, I don't know how it was before. – Adam Byrtek – 2011-05-31T01:11:37.530

EXACTLY what I was looking for! I played a lot with this file, with 'antialias', 'hinting', 'hintstyle', 'rgba' and 'lcdfilter' options, and nothing helped. 'autohint' did it! Just a note: you must have rgba=none for autohint to work correctly. Seems like autohint is enabled by default in Fedora, but not in Ubuntu. – Juliano – 2009-07-20T01:31:56.390

5

As John said it, the ~/.fonts.conf file is useful to tweak your font configuration.

I eventually figured out how it works after reading this article :

http://www.kilobitspersecond.com/2009/04/17/ubuntu-font-hinting-you-a-cautionary-tale/

Maxime R.

Posted 2009-07-19T23:22:23.070

Reputation: 2 166

0

The latest versions of Ubuntu allows changing these settings via Preferences > Appearance > Fonts > Details

I find Medium hinting to be the most pleasing on my LCD screen.

JannieT

Posted 2009-07-19T23:22:23.070

Reputation: 981

Yes, the hinting option is already known. The "autohint" option, as mentioned by John T, is the option that is missing in that dialog, including in the latest version of Ubuntu. – Juliano – 2010-08-12T13:52:14.403