April 17, 2014

.comment: A Whole New Desktop with Anti-Aliasing - page 3

A Really Polished Look for Linux

  • March 14, 2001
  • By Dennis E. Powell

Okay, first, in case I forget it later: If you are running KDE-2.x and you have a ~/.kde/share/config/kdefonts, rename it at once! (Do not delete Linux configuration files until a few days after you've renamed them, when you're sure you don't need them. Give them very silly names, so that you'll be able to pick them out in case you need them after all. Names like "longpurplewhiskerskdefonts." It's a good idea to keep the original name in there so that you'll know what to name it back to if you need to do that.)

Second, make sure that you're not wasting your time, which is to say make sure that your video card is supported. If you're not running XFree86-4.02, you ought to be anyway if your video card is supported. If you are running it, open a terminal emulator and do xdpyinfo, which will provide all kinds of obscure information about your video system. Scroll through it until you find a section headed "number of extensions:" followed by a number. The extensions you have available are listed, in alphabetical order. If RENDER is among them, you've passed the first test.

(Here it can be a little complicated if you've not built your XFree from source. If you compile it yourself, you'll need to make sure your source tree's /xc/config/cf/host.def file contains a line pointing to the location of your Freetype2 installation, to wit:

#define Freetype2Dir /usr/local

This is the default location for Freetype2. It is included in the XFree distribution, but must be compiled separately. It's found in /xc/extras/freetype2. Go there, do make setup followed by make and, as root, make install. Then go ahead and build your XFree. The reason it's complicated if you haven't built it yourself is that you're at the mercy of whoever it was who built the binary packages you're using, who may or may not have done so with anti-aliasing in mind.)

Presuming XFree-4.02 or better, presuming the existence of Freetype2 on your machine, and presuming the existence of libXft on your machine (all of which can be confirmed by use of the locate command), and further presuming therefore that you found RENDER, the next step is to get rid of any font server you have running. This is a two-step process. First is looking at /etc/X11/XF86Config and finding any FontPath line that points to something like unix/:7100 or unix/:anythingelse. comment it out with a pound sign and a space afterwards -- remember, the idea is to do nothing irreversible. If you have lines that point to /usr/X11R6/lib/X11/fonts/truetype and /usr/X11R6/X11/fonts/Type1 visit the pound-space (# ) on them, too. While you're there, make sure that the Section'Module' section includes:

Load "type1"

Load "freetype"

Now. If your distribution was assembled by vicious morons, the FontPath lines will list nothing but your font server, rather than the proper method of including all the font directories, commented out. This would not be an enormous concern but for one essential; if you do not have it, then where you commented out the FontPath unix/:yadayada line, insert another line:

FontPath "/usr/X11R6/lib/X11/fonts/misc"

In a multitude of experiments with anti-aliasing, I have not found a configuration that allows the elimination of this. Fact is, there are numerous FontPath lines you might want to leave. Here's the appropriate section from mine:

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
# FontPath "unix/:7100"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
# FontPath "/usr/X11R6/lib/X11/fonts/truetype"
# FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/local"
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
Fontpath "/usr/X11R6/lib/X11/fonts/Speedo"
ModulePath "/usr/X11R6/lib/modules"

This will see you through, because some applications will want XFree86-provided typefaces that you might not have in anti-aliased form. Feel free to copy and paste from the above, with these caveats: If you don't actually have those directories, they'll do you no good, and if you're not running at high resolution, 1024x768 or above, you'll want to reverse the 100dpi and 75dpi lines or your screen fonts may be bigger than you expect, especially in non-KDE applications you run under KDE.

You noticed, perhaps, that the truetype and Type1 lines have been commented out in my example. This is not a gift from the gods. You need to tell the system, elsewhere, about their existence. You do this in a file whose fully qualified name is /usr/X11R6/lib/X11/XftConfig. Mine, until I understand more about its apparently vast potential, comprises this:

dir "/usr/X11R6/lib/X11/fonts/Type1"
dir "/usr/X11R6/lib/X11/fonts/truetype"

(Keith Packard, who assumes the best of Linux users, has built in lots of possibilities that will substitute anti-aliased fonts for the ones demanded by non-KDE applications. His prototype XftConfig file, and TrueType typefaces for those who lack them, does this, and it's probably more self-explanatory to most people than it was to me; fact is, you can probably just pop it in and live in happiness forever. While I very much appreciate Keith's tremendous work, I fall back on the likes of David Faure and Kurt Wall, who recognize that some of us are dimwitted and allow for it.)

Now it's time to get or build an Xft-enabled QT-2.3.0. If you're building it, add -xft to the already long ./configure line. I do not know whether people who have packaged QT-2.3.0 as a binary have enabled anti-aliasing or not, except for packages built for Debian. Ivan E. Moore II, another hero of the community in my estimation, has built QT and KDE-2.1 for anti-aliasing, and the XFree86-4.02 that Debian offers has new enhancements. They're in, Ivan tells me, the sid/unstable tree. (Another argument in favor of Debian, but more than that another argument in favor of learning how to compile your own stuff -- distributions are going to morph into God-knows-what in the coming months, and in any case it frees you from one level of dependence on others.) If you're not running Debian, and if you're not of a mind to roll your own, you'll need to inquire of your distributor. Good luck.

Once you have QT-2.3.0 with the Xft extensions, you're pretty much home free. If you didn't get your KDE-2.1 -- you are running 2.1 if you're running KDE, right? No? Well, get it! -- from Debian, or build it from source against Xft-enabled QT-2.3.0, there's one thing more to do. It's an environment variable, export QT_XFT=true, which is a good thing to put in your ~/.xinitrc as the very first line.

If, however, you got Ivan's binaries or you built against QT-2.3.0, this isn't necessary. Once you start KDE, go to the K menu > Preferences > Look & Feel > Style. This will now contain a checkbox next to "Use Anti-Aliasing for Fonts and Icons." Check it and restart KDE. Anti-aliasing is yours!