Feeds

Fabulous fonts in Linux

It's easier than you think

  • alert
  • submit to reddit

The Power of One Brief: Top reasons to choose HP BladeSystem

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"

The Essential Guide to IT Transformation

More from The Register

next story
KDE releases ice-cream coloured Plasma 5 just in time for summer
Melty but refreshing - popular rival to Mint's Cinnamon's still a work in progress
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Secure microkernel that uses maths to be 'bug free' goes open source
Hacker-repelling, drone-protecting code will soon be yours to tweak as you see fit
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
Put down that Oracle database patch: It could cost $23,000 per CPU
On-by-default INMEMORY tech a boon for developers ... as long as they can afford it
Another day, another Firefox: Version 31 is upon us ALREADY
Web devs, Mozilla really wants you to like this one
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
prev story

Whitepapers

Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Consolidation: The Foundation for IT Business Transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.
Application security programs and practises
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Securing Web Applications Made Simple and Scalable
Learn how automated security testing can provide a simple and scalable way to protect your web applications.