X Grows Up

It's faster. It handles fonts better. It has better 3D support and every graphics-board manufacturer is writing drivers for it. XFree86 4.0 is finally here. We tell you what it delivers and show you how to install it.

Everyone wants to see Linux grab a bigger share of the desktop-computing market. Well, with the release of XFree86 4.0, one of the biggest obstacles to Linux’s acceptance as a desktop platform has just been overcome. XFree86 is a free, open source implementation of the X Window System (often referred to as ‘X’ for short), and it provides the graphics and windowing infrastructure that forms the foundation of GNOME, KDE, and all the other GUI (Graphical User Interface) applications that we know and love. Although many Linux advocates will tell you that the most important advancement in the operating system’s development to date is the new 2.4 kernel, from the end user’s perspective the kernel is of relatively little interest — it just needs to work, period. Just like under Microsoft Windows, it’s the GUI environment and the applications that run under it that make all the difference in the world.

XFree86 has been around for several years now, but until the advent of XFree86 4.0 it was for the most part a hodge-podge of graphics drivers and code that was very difficult to install, was abysmally slow, had lackluster font support, and was a chore to maintain. Worse yet, it wasn’t well-integrated with the open source 3D OpenGL subsystem, Mesa3D, which provides the crucial 3D support layer for our favorite games (like Quake) and professional 3D graphics programs (like Alias). Finally, adding insult to insult, XFree86 support by third-party manufacturers was tepid at best. Like everything else open source, support for graphics cards and their more advanced features was a best effort among hundreds of programmers around the world.

Nevertheless, if you wanted a completely free and platform-independent implementation of X (as opposed to the commercial versions sold by third-party vendors like Xi Graphics and Metro Link for hundreds of dollars), XFree86 was the only game in town. But now that Linux and the companies surrounding it have become almost household words and the darlings of Wall Street, virtually every graphics-chip manufacturer has XFree86 drivers in development, and we’ve just started to see some very good 3D graphics applications and games come sprouting out of the woodwork. And if it’s any indication of what else is to come, the crown jewel of computer-graphics companies, SGI, has staked its entire future on Linux. For a great many people in the Linux and open source communities, 2000 will be remembered as the year XFree86 and Linux 3D support finally grew up.

What’s new in xfree86 4.0

Nearly everything in XFree86 has been redesigned from the ground up. The most noticeable change is that for 2D graphics, XFree86 4.0 is fast. How fast? While we don’t have any exact numbers yet, preliminary tests by graphics-card manufacturers show that the XAA (XFree86 Acceleration Architecture) in many cases is actually faster than the leading commercial alternatives — a very impressive accomplishment for a scattered bunch of open source programmers. In addition to the dramatic performance increase, XFree86 is built upon a singular modular X server that uses loadable driver modules instead of having different X servers for each major graphics chipset. This will allow for easier driver development and (hopefully) for more frequent driver updates by video-chipset manufacturers.

The second most important advancement in XFree86 4.0 is the inclusion of Precision Insight’s DRI (Direct Rendering Infrastructure) technology. DRI provides a highly optimized channel for sending 3D graphics commands directly to the video hardware, and allows for the display of accelerated 3D graphics within an X11 window. In previous releases of XFree86, this could only be achieved by having graphics-card vendors create their own proprietary extensions. But DRI is here because SGI, in cooperation with Precision Insight and the XFree86 project, open-sourced its GLX library, which provides the important link between the windowing system and the Mesa 3D-rendering engine (which implements OpenGL). With DRI, graphics-chipset vendors now have a standardized and modular foundation to target with their 3D drivers, much like the Direct3D abstraction layer that exists in Microsoft Windows.

As shown in Figure One, non-direct-rendered 3D applications go through the X server during rendering operations, while applications written to take advantage of the DRI bypass the X server during rendering. Both paths use Mesa as an implementation of the OpenGL API, but the indirect path also uses GLX to display nonaccelerated 3D applications in windowed mode.

As of this writing, only 3dfx Voodoo3 and Banshee cards are capable of using DRI with XFree86 4.0 “out of the box,” but drivers from Matrox, ATI, and Intel are forthcoming in the second quarter of 2000. If you’re using NVidia’s TNT, TNT2, or GeForce cards, don’t despair — while NVidia isn’t writing 3D drivers to the DRI specification, it’s working on its own set of hardware-accelerated Mesa OpenGL drivers for XFree86 4.0 (in binary form only, however).

We won’t be discussing how to install or configure DRI drivers in this article, since that support is still limited, and the procedures might change in the near future. You can count on our covering it in a future article.

While not as sexy as hardware-accelerated OpenGL, XFree86 4.0 is the first release to support TrueType fonts out of the box, which should bring a huge sigh of relief to graphics and publishing professionals as well as end users looking to use their favorite Windows fonts (see pg. 51). CAD freaks as well as those with a need for the ultimate in screen real estate will also appreciate XFree86 4.0′s Xinerama technology, which allows you to use two monitors and two video cards at the same time as a single X desktop.

A Few Words of Caution

Now that you’ve read about XFree86 4.0′s improvements, you’ll probably want to download it and install it yourself. A caveat before you start: While XFree86 4.0 is release code, it’s still very much under development, so unless you really feel the need for speed and need to take advantage of these features, it’s probably best to wait until the distributions start implementing it as part of their installation routines and provide a painless upgrade path. SuSE has announced that version 6.4 of its Linux distribution will include XFree86 4.0 preinstalled. MandrakeSoft has plans to include XFree86 4.0 in Linux-Mandrake 7.1 this summer as well, although Red Hat has opted to use version 3.3.6 in its 6.2 release.

It’s also worth pointing out that some video cards from the previous 3.3.6 release of XFree86 aren’t supported yet, so you’ll want to double-check the hardware-compatibility list to make sure 4.0 really will work with your card.

Figure One: XFree86 4.0′s new direct rendering infrastructure.

Configuring and installing from Binaries

So, assuming you aren’t scared off yet, you can retrieve the XFree86 4.0 Linux binaries by connecting to the Internet and FTPing to ftp.xfree86.org. XFree86 4.0 is a large download, about 40 MB in all, so you’ll want to make sure you download it using an FTP client with auto-resume capabilities, like ncftp, just in case your file transfer is interrupted.

Virtually every Linux distribution has ncftp installed by default, so all you have to do is type the following command from the terminal prompt (preferably from within a newly created subdirectory of your /home directory):

ncftp ftp.xfree86.org <enter>

ncftp has automatic anonymous logins enabled by default, so if your connection is successful you should now be dumped into the root FTP directory of xfree86.org.

If you’re running a recent Linux distribution on an Intel machine using the 2.2.x series of kernels, such as Red Hat 6.x, Linux-Mandrake 7.0, Caldera 2.3, or Corel Linux 1.x, change to the following directory on the XFree86 FTP site by typing the following:

cd /pub/XFree86/4.0/binaries/Linux-ix86-glibc21 <enter>

Next, type

mget * <enter> mget * <enter>

after which, depending on the speed of your Internet connection, you should take a short coffee break or go out and see a good movie, and perhaps a dinner date with your significant other, if you’re lucky enough to have one. If by the time you get back that you notice your transfer has timed out, you can simply reconnect, type mget * from whence you left off, answer “N” to the overwrite prompts, and resume downloading.

You should have a total of 34 files in your temporary directory, including these. Once you have them all, you’re ready to install XFree86. If you have an existing version of XFree86 running on your machine, don’t worry, you can upgrade over it just fine. But before you do this, bring Linux down to single-user mode by typing the following command at a terminal prompt:

init 3 <enter>

This will immediately shut down your X server and bring you to the console, after which you can log in as root and run the following command from the directory to which you downloaded the XFree86 4.0 files:

This will fire up the XFree86 installation routine, which will ask you a few questions. The preferred responses in the sample session to the right are shown as they would appear on your screen.

The installation script will ask you several questions about replacing various configuration files on your system. Answer “yes” to all of them. You’ll then see a list of messages telling you that various archive files (all with names ending in .tgz) are being extracted.

Note: These files are installed in /usr/lib/X11/doc/html.

Note: The PostScript documentation, which is installed in /usr/lib/X11/doc/PostScript can be viewed with the Ghostscript Viewer utility, covered in this month’s On the Desktop (pg. 82).

You will then be prompted to install a whole bunch of different files — simply answer “Y” to all of the questions, with the exception of the Japanese docs (to our Japanese Linux Magazine readers, our apologies).

The installer will then attempt to extract the font files to their proper directories — if you get errors or warnings that you already have these fonts installed, don’t worry about it. Finally, the installer may prompt you for action regarding your termcap file.

Fom a shell prompt, run the following command:

xf86config <enter>

You will then be presented with the text in the figure at top right, and you should hit Enter. This will take you to the next step, which is configuring your mouse. Since I own a Logitech Trackman Marble FX, which emulates a PS/2 or Microsoft mouse, I can choose option 1 or 4.

On my system, I use a bus (PS/2-style) mouse port, so for this question I specify my mouse port as /dev/psaux. If you’re using a serial mouse attached to COM1 or COM2, this should translate to /dev/ ttys0 and /dev/ttys1 respectively.

If you have a standard PC keyboard, you should choose option 1.

Choose the appropriate language, which for me is English and option 1.

The next step requires some care and likely a little research using your monitor’s manual or possibly the Web site of the monitor’s manufacturer or the provided XFree86 documentation. You’ll be asked for the horizontal and vertical refresh rates of your monitor, which XFree86 uses to determine the best (highest) refresh rate it can safely use for each resolution. The installation program will describe this step and then ask you to hit enter. Note that you can seriously damage your monitor if you enter the wrong values.

I own a 21″ Hitachi CM802 which has a maximum horizontal refresh rate of 76 at 1280 x 1024, so I chose option 10.

The installation program next asks you to provide some text names or descriptions for your monitor. Normally you don’t care what these are, and you can just press Enter to let the program use default values. To page through the list of video cards, just hit the Enter key. When you find your video card, or a card that uses the same video chipset as your card (such as s3 Virge, RIVA TNT2, ATI, Matrox, etc.), simply type the corresponding number in and hit the Enter key.

Now it’s time to configure your video card. The installation program displays the text in the figure below. You should answer “y” to see the video card list, and then pick the right entry. Since I have a NVIDIA TNT2-based card, the Diamond Viper V770 Ultra, I chose entry number 230.

The installation program will show you the settings for your card, and ask you to press Enter to continue.

XFree86 needs to know how much memory is on your video card, which is the next question. Since I have 32 MB of memory on my video card, I multiplied 1024 x 32 (1024K = 1 MB), which gives me 32768 Kbytes.

You’re then asked to provide a name and descriptions for the video card. I use the make and model of my card, Viper V770, but you can just press Enter to use the default values, similar to the monitor name and description step above.

You must tell XFree86 which resolutions you wish to use at various color depths. The installation program will show you a list of the resolutions for each depth, and let you change them. I just chose option 4, to accept the program’s defaults.

You also get to select which color depth you want XFree86 to use by default, as shown in the figure below. Most people select at least 16 bits/65,536 colors, since it often results in much more appealing screens, such as when you’re using a complex theme.

Finally, the moment you’ve been waiting for–you’ll be prompted to save the configuration file:

After the utility kicks you out to the prompt, you should issue the following command to bring Linux into multiuser mode and to relaunch your X server:

init 5

If all goes well, you should now be running XFree86 4.0. Congratulations! When X starts up, you might notice that the default resolution is at 640×480 — simply hit ctrl-alt-+ (using the plus sign on the numeric keypad) to dynamically change your screen resolution.

Once you’ve gotten XFree86 4.0 up and running, you’ll probably want to start using your favorite TrueType fonts from Microsoft Windows or the Internet. The first thing you’ll need to do is make sure that the TrueType XFree86 module is running on your system.

Step 1: Edit

Edit the file /etc/X11/XF86Config with any text editor. Make sure the following statements are in your “Module” section:

This loads the freetype open source TrueType font module for Linux, as well as the Adobe Type 1 fonts that are used on Macintosh and Windows systems.

Next, you’ll want to add a new directory to your X font path in the following section. Save the file and close your editor. If you had to modify XF86Config, you should restart your X server by hitting ctrl-alt-backspace.

Next, you’ll want to create a new directory under /usr/X11R6/lib/X11/fonts called TrueType. Simply type the following commands from the prompt

cd /usr/X11R6/lib/X11/fonts
mkdir TrueType

Step 4: Transfer Your Truetype Fonts

You’ll now want to transfer your TrueType fonts to this directory. Since I have a LAN at home, I simply FTPed the *.TTF files from my Windows 2000 workstation’s \WINNT\fonts directory to a temporary subdirectory on my /home mountpoint, and copied them using KFM.

Step 5: Make Your Truetype Fonts Usable

To make the TrueType fonts in /usr/X11R6/lib/X11/fonts/TrueType usable under XFree86 4.0, you need to use a utility called ttmkfdir, which you can download from Freshmeat.net, or from the author’s homepage at http://www.darmstadt.gmd.de/~pommnitz/TrueType/ttmkfdir.tar.gz. What ttmkfdir does is scan TrueType fonts and create index files, or font.dir files, which XFree86 reads to catalog your list of fonts, and make these accessible to all of your X applications. The archive file ttmkfdir.tar.gz contains the source code as well as a precompiled binary for Intel Linux machines named ttmkfdir.linuxbin.glibc2. Rename this file to ttmkfdir and copy it to your /usr/bin directory.

To index your TrueType files just cd to /usr/X11R6/lib/X11/fonts/TrueType and use the following command:

ttmkfdir > fonts.dir

Font Master: A plethora of TrueType fonts can be used in the GIMP.

Step 6: Make Fonts Available

To make the fonts available to your GUI programs, you have to shut down and restart X. And there you have it — you should be able to access your TrueType fonts from any X application.le