Saturday, 3 December 2011

Tutorial - Recompiling Freetype with the patented auto hinter enabled in openSUSE 12.1

Here is a great little exercise that will teach you how to recompile the freetype package in openSUSE 12.1 and enable the patented auto hinter for better looking fonts.

Start by opening a terminal.

Install required packages such as gcc and zlib-devel

su -c 'zypper install gcc zlib-devel patch'

Change to your Downloads folder

cd Downloads

We are going to download the freetype source rpm package from the openSUSE servers.

wget http://download.opensuse.org/source/distribution/12.1/repo/oss/suse/src/freetype2-2.4.7-1.2.src.rpm

At the time of writing 2.4.7-1.2 was the current available version.

Install the source package locally

rpm -ivh freetype2-2.4.7-1.2.src.rpm

A new folder will be created in your home directory called rpmbuild.

cd ~/rpmbuild/SPECS

We need to edit the freetype2.spec file so it compiles with the auto hinter enabled.

kwrite freetype2.spec

Scroll down to line 80 and change %define enable_subpixel_rendering to %define enable_subpixel_rendering 1

Save and exit

It is now time to compile our modified freetype package, which should not take very long.

rpmbuild -bb freetype2.spec

Once the package has been successfully compiled, it will be located in the rpmbuild/RPMS/x86_64 or rpmbuild/RPMS/x86 folder.

To install your modified freetype package,

cd ~/rpmbuild/RPMS/$(arch)

su -c 'zypper install --force libfreetype6-2.4.7-1.2.$(arch).rpm'

You have now installed your modified freetype package, reboot your machine to see the difference.

Important Note:

Installing your modified freetype package will overwrite the existing freetype package that has the patented code disabled. However, should openSUSE install an update to freetype it will overwrite your modified freetype package.