# As root: dnf install @development-tools dnf install fedora-packager dnf install rpmdevtools /usr/sbin/useradd makerpm usermod -a -G mock makerpm passwd makerpm # As the new user. rpmdev-setuptree
I was pleasantly surprised a couple of days ago with the way the freetype library is packaged in Fedora, when I removed every trace of RPMFusion from my system and attempted to rebuild freetype with subpixel rendering support.
As I mentioned sometimes in the past, I prefer to package the missing bits in a Fedora installation myself, but I had RPMFusion installed, and normally disabled, to have easy access to Steam and freetype-freeworld, an alternative freetype package with subpixel rendering enabled.
Subpixel rendering is a technology that’s patented in some parts of the world (not my home country) and is disabled by Fedora in the freetype package for mere legal reasons. The freetype project includes an implementation in its source code.
A few days ago I decided to uninstall Steam from my Linux system and, with it, every other i686 package. The only thing left from RPMFusion was freetype-freeworld.
When I investigated how to build freetype myself to create my own freetype package with subpixel rendering enabled, I found a nice surprise. The freetype package maintainer has included some code in the package SPEC file that makes it trivial to rebuild with subpixel rendering in a few commands. Here’s how.
There are some things to set up only once for the first time, as taken from the Fedora guide on how to create RPMs. You should install some packages and package groups in your system, you should add a new user to build packages as and, finally, you should prepare an RPM-building environment for that user.
I called my user “build” instead of makerpm, but the username is irrelevant. You also need to install every package that’s required to build the freetype package and is, as such, listed as “BuildRequires” in the SPEC file. As of the time I’m writing this, these are libX11-devel, libpng-devel, zlib-devel and bzip2-devel.
# As root. dnf install libX11-devel libpng-devel zlib-devel bzip2-devel
Every time you want to rebuild the freetype package
The first time, or when Fedora updates the freetype package (it doesn’t happen very frequently), you’ll find out your font rendering is bad again. Only three commands are needed to rebuild the package.
First, download the source RPM for the package and rebuild it.
# As the RPM-building user. cd ~/rpmbuild/SRPMS dnf download --source freetype rpmbuild --rebuild --with subpixel_rendering freetype-WHATEVER.src.rpm
The key here is the patch the freetype package maintainer provides to activate subpixel rendering, and everything that’s set up so calling rpmbuild with the --with subpixel_rendering option applies the patch and builds a package with the technology activated. Great job on their part.
Finally, proceed to reinstall your custom version of the packages.
# As root. cd /home/makerpm/rpmbuild/RPMS/x86_64 dnf reinstall ./freetype-WHATEVER.rpm
Then, restart your X applications, or restart the whole X11 GUI or simply reboot and your font rendering will be good again.