This article is more than 1 year old

Fabulous fonts in Linux

It's easier than you think

Howto One of the more common disappointments reported about the Linux GUI is clunky fonts under X. While it's true that they can look pretty rough out of the box, it's also true that sharpening them up is easy and well worth the effort, thanks to MS TrueType fonts and the open-source FreeType project which makes them useable on Linux. What follows is an explanation of how to tweak them, assuming KDE is your desktop manager. (I imagine this may work on other desktops, but KDE is the only one I'm well acquainted with.)

The first step is to download and install the MS TrueType core fonts. These used to be available from MS but are no longer, though they can be had now courtesy of SourceForge here, along with detailed instructions for downloading and installing them. You'll have to download a source RPM and then build a binary RPM. If you're a newbie and this sounds intimidating, there's a simpler alternative if you have an existing Windows image on your Linux machine: simply copy the desired fonts from the Windows partition to a directory on your Linux partition. My guess is that if you've paid MS for the privilege of using their fonts, you can use them with another OS so long as you don't distribute them without permission.

Now, merely having TTFs or anti-aliasing isn't enough. Take a look at this screen shot of TTFs in an OpenOffice.org document. They're clunky and blocky and basically impossible to distinguish from each other. However, with a bit of tweaking we can make them look distinct, slick and refined, as you can see in this screen shot.

The difference between the two is a feature in FreeType which is turned off by default. You may have anti-aliasing selected via the KDE Control Center, but unless you build the FreeType font engine with a trick I'm going to explain, this setting has little or no beneficial effect on TrueType fonts.

Due to licensing hassles, FreeType is distributed with some TTF support switched off. Thus we have to build FreeType so that this feature is available, a procedure which, fortunately, is quite easy. That's the only difference in the two screenies above -- the first was shot with FreeType in its default configuration, the second with FreeType tweaked in the manner that I'm about to describe.

First you need to download the FreeType source tarball and unpack it in a convenient directory, probably /root since some of what we have to do needs to be done as root anyway. Once it's unpacked you need to edit a file in the FreeType directory: go to freetype-2.x.x/include/freetype/config/ftoption.h and open it in a text editor. Now find the line in ftoption.h which reads
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER and change it to
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER. Save your change.

Now bust out a shell and find out where FT should be installed with the command freetype-config --prefix. This will tell you where it's installed on your system, if you have it installed. Install the new version in the same directory with the prefix command. For example, assuming it's in /usr/local, you would start with the command ./configure --prefix=/usr/local and so on. If you don't have FT installed, it defaults to /usr which is fine. Now just run ./configure --yourprefix, then make, then make install and you're almost home.

There's a little issue with XF86 version 4 which makes it prudent to do the installation again in /usr/X11R6, following the steps above. When you upgrade FT, you'll have to install in both directories again.

All right, now you have your TTFs copied and your FreeType engine installed. Now it's time to make them available. Re-start X, and then open the KDE Control Center as root. Go to System, Font Installer. Click the tab 'Anti-Alias' and tick 'Use sub-pixel hinting'. Now click the 'Fonts' tab. On the left you'll find a tree designating the directory to install the TrueType fonts from. Select whatever directory you copied them into originally. On the right you'll find a tree designating the directory to install the fonts to, typically /usr/X11R6/lib/X11/fonts/truetype. Set the directories and then select all the TrueType fonts in the source directory and click on 'Install'. In a moment they should all show up in the destination directory. Now click 'Apply' and OK on any error messages you might get.

That's all there is to it. Re-start X again, and all your apps should be able to exploit the new fonts, except OpenOffice.org, which needs an extra step. You can open Krusader or Konqueror or Mozilla and in the fonts sections find the TTFs to be applied according to your choice. You can apply them to the KDE desktop with Control Center, Look & Feel, Fonts (make sure 'use anti-aliasing' is ticked), and Control Center, Look & Feel, Desktop. You can apply them to Kedit and Kmail and a score of other apps.

For OpenOffice.org you need to install the fonts again manually. Go to your OO.o directory and execute the file, spadmin. Go to Fonts, Add, and choose the source directory, /usr/X11R6/lib/X11/fonts/truetype. When the fonts are visible in the window, click on 'Select All' and then 'OK'. You'll then be given a choice of copying the fonts to your OO.o directory or linking to them. Either will work.

All right; you've done it. Below are screen shots illustrating how handsome KDE can be with TrueType fonts properly supported and configured. This is what I'm looking at; there's no reason why you shouldn't be too. ®

KDE Control
Krusader
Mozilla1
Mozilla2

Note, several readers have pointed out that this technique seems to break anti-aliasing. It does, but not universally. Some fonts will have it and some won't. However, merely disabling anti-aliasing definitely doesn't work as well as enabling the bytecode interpreter. Regardless of the side-effects, the result is a KDE desktop that's easy to look at, imho. --tcg

Caveats

Reader Simon Burns reports that installing FreeType from source on Red Hat 8 made his KDE desktop disappear. He fixed it by deleting libfreetype* from /usr/X11R6/lib and /usr/lib and installing the Red Hat FT RPMs.

Reader Adam Williamson believes that Mandrake users should avoid building the FT package from source. He says, "Mandrake users should not rebuild FreeType; they should simply use the FreeType RPMs from PLF - the Penguin Liberation Front - which are stock Mandrake RPMs, but rebuilt with the bytecode interpreter enabled. If you run Mandrake 9.0, the appropriate RPM is at: http://plf.wwwhost.biz/files/9.0/i586/freetype2-2.0.9-3plf.i586.rpm"

More about

TIP US OFF

Send us news


Other stories you might like