Font rendering is a matter of taste. However, I personally think Ubuntu’s default font rendering is the most eye-pleasing one of the whole Linux eco-system. And if a website’s CSS font stack is looking good on Ubuntu, you can be relatively sure that it also works for Mac or MS Windows as long as the used fonts are available on these platforms. It is not hard to get the same font rendering on Fedora. This text is just a bit longer than a few commands because I try to provide additional background information and useful web-search-keywords which you may need if you have other targets than a 100% Ubuntu-like rendering.
To achieve the desired result, you have to know which parameters exist and how to change them. The most important things are:
Font hinting and the used font hinting method.
Font rasterization. Especially the used anti-aliasing method and its strength.
The used font rendering engine. The one shipped with Fedora comes without subpixel rendering (more on this later).
So let’s look at the defaults applied on Ubuntu 10.10. You can do this on the terminal with
Xft.dpi: 96 Xft.antialias: 1 Xft.hinting: 1 Xft.hintstyle: hintslight Xft.rgba: rgb Xft.lcdfilter: lcddefault
As you can see, Ubuntu is using RGB anti-aliasing with subpixel rendering (lcd-default means “subpixel (LCD)” method) and slight font hinting. Now compare this with the default values on Fedora 15 Lovelock:
Xft.antialias: 1 Xft.dpi: 96 Xft.hinting: 1 Xft.hintstyle: hintmedium Xft.rgba: none
This shows that Fedora does use grayscale anti-aliasing, a stronger font hinting style and no subpixel rendering by default. This is the reason why the same fonts look different on Fedora and Ubuntu.
What to do
Install the freetype-freeworld package. You need subpixel rendering the achieve the same results as on Ubuntu. The FreeType rendering engine shipped by default comes without it but you can install the
freetype-freeworldpackage out of the RMPfusion-free repository to get a version with subpixel rendering. If not already happend, enable RPM Fusion on your system. Open a terminal and install the
su -c "yum install freetype-freeworld"
You should know that subpixel rendering is patented and therefore not completely free (as in speech). Using this package might not be legal in your country. The choice is yours and it is your legal responsibility to make sure that the software you are installing can be legally used.
Adjust the hinting style and enable RGB anti-aliasing. Ubuntu it using
hintslighthinting by default, Fedora comes with
hintmedium. Additionally, we need RGB instead of grayscale anti-aliasing. Open a terminal and execute the following commands to set the anti-aliasing and hinting style:
gsettings "set" "org.gnome.settings-daemon.plugins.xsettings" "hinting" "slight" gsettings "set" "org.gnome.settings-daemon.plugins.xsettings" "antialiasing" "rgba"
Activate the lcddefault lcdfilter. Unfortunately, there is no GSettings key for it (at least as I’m writing this), therefore you have to create a hidden
.Xresourcefile with the
Xft.lcdfilter: lcddefaultsetting in your home directory. Open a terminal and execute the following command to do so:
echo "Xft.lcdfilter: lcddefault" > ~/.Xresources
Some settings need a restart to take effect, so reboot your system. If everything worked you should get the following
xrdb -queryoutput (the output order does not matter if the values are the same):
Xft.antialias: 1 Xft.dpi: 96 Xft.hinting: 1 Xft.hintstyle: hintslight Xft.lcdfilter: lcddefault Xft.rgba: rgb
You may find the
gnome-tweak-toolinteresting. E.g. it provides an option to switch the window-title-bar font. Use the following command to install it:
su -c "yum install gnome-tweak-tool"
I used the command line tool
gsettingsto adjust the GSettings key values above. If you want to influence and explore available keys by using a GUI, have a look at the
dconf-editor. Use the following command to install it:
su -c "yum install dconf-editor"
You may want to use the Ubuntu fonts, too. They are not included in the main repositories right now,1)therefore I wrote the
install-ubuntufonts-fedora.shbash script to make the font installation faster and easier. There is a high probability that this script will never be useful to someone else than myself. But you never know. If you want to use it, open a terminal and run the following commands to download and execute it (copy and paste recommended):
wget "http://blog.andreas-haerter.com/_export/code/2011/07/18/install-ubuntufonts-fedora.sh?codeblock=1" -O "/tmp/install-ubuntufonts-fedora.sh" chmod a+rx "/tmp/install-ubuntufonts-fedora.sh" su -c "/tmp/install-ubuntufonts-fedora.sh"
Please read the Ubuntu Font Licence for all the rules that govern the use of the fonts.
If you want to go any further, you should know some things about the fontconfig system. First of all, it is controlled by
*.conffiles. Fedora is looking for them at the
/etc/fonts/conf.d/directory and they get imported in alphabetical order.2) Please note that every file in this directory should be a symlink pointing to a real config file located in
/etc/fonts/conf.avail/. This makes it possible to deactivate settings by deleting the symlink in
/etc/fonts/conf.d/without loosing the corresponding config file in
/etc/fonts/conf.avail/. It is also recommended to follow the rule “one setting, one file”. This makes sure you always know which files configures what.
All settings at
/etc/fonts/conf.d/are affecting all user accounts and therefore you need root privileges to create or edit the files. If you want to influence only a specific user account, it is also possible to place files in the user’s
~/.fontconfig/directory (simply create it if it is not already existing).
I assume that your display is using RGB pixels (the subpixel layout test page can help you to verify this). If your monitor is using BGR, V-RGB, or V-BGR pixels, you might want to use another anti-aliasing setting than
read count : 40339