Articles

Patching Cairo

In Ubuntu on 01/08/2010 by weirdfellow

I had it enough… GTK applications are respecting some of the Fontconfig setting (you can switch antialias or hinting on/off), but others were just ignored (it wasn’t possible to specify hintstyle or switch between grayscale and subpixel antialiasing)… Not only I have had issue with that – in my case the “quasi-bitmap” fonts used for programming look much better with grayscale AA. There were some ad-hoc patches, for instance cairo-respect-fontconfig, but they don’t really fix the problem – just sweep the problem under the carpet.

First of all I had to decode what is used to render fonts in Gnome. After identifying that the bugs are in Cairo, I decided to compile it myself. After a bit of the struggle with missing libraries – thank you Ubuntu for Synaptic Package Manager – I managed to compile Cairo 1.8.10. I have applied patches shipped with Ubuntu and started to look into the problems.

The functions dealing with properties returned by Fontconfig have been rewritten and profusely commented – patch file and binary package available to download below.

Be aware: After the installation, you might notice that the Appearance panel seems not to work. This behavior is intentional and absolutely OK.
Gnome does not save it’s settings in Fontconfig registry, and by default Fontconfig comes with some settings – they are stored in files in /etc/fonts/conf.d. By default they cover switching on antialiasing (10-antialias.conf) and switching on slight hinting (10-hinting-slight.conf). In the result Fontconfig will always override those two settings.

As a workaround, remove those two mentioned symbolic links, and the panel will start to behave correctly again. Files 10-hinting.conf and 11-lcd-filter-lcddefault.conf are ok and should stay in /etc/fonts/conf.d. The long term solution would be for Gnome to save the font settings in the Fontconfig registry too – I am working on the plug-in for gnome-settings-daemon, that would do this.

Downloading

The source of Cairo is available from the project homepage, but I downloaded the source package from Ubuntu launchpad – this version does not require autoconf, you can just call ./configure.

Patching

Ubuntu patches are to be downloaded from here. Each patch is to be executed from cairo-1.8.10 directory in following manner:
$ patch -p 1 <path-to-the-patch-file. After applying Ubuntu patches, you can apply my patch.

Compilation

My version of library would compile, but it was much bigger than the one shipped within distro. Setting environment variables to skip debug information and add some optimizations prior executing configure (export CFLAGS='-Wall -g0 -O0 -O2') helped a lot. After successful execution of configure and make, the result can be found in src/.libs directory. Copy it into the /usr/lib folder and restart X.

Results and downloads

Finally I have fonts that work as I want.

Patch file from Rapidshare
Binary package from in progress.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: