If you’ve migrated users to StarOffice, chances are that they’re experiencing TrueType envy. After all, this scalable font technology is the norm for Windows and Mac systems, but it isn’t installed by default on Linux systems. That’s a shame, because there are literally thousands of TrueType fonts available, and many of them are in the public domain or freely available for virtually unrestricted use. Among them are many beautiful fonts that can greatly enhance StarOffice output, including StarImpress presentations and StarWriter documents.

Here’s the good news: As I’m sure you’ve realized, you can get TrueType to work on Linux systems—and it’s particularly easy if you’re running Red Hat 6.0, 6.1, or derivatives (including Mandrake). What’s more, StarOffice can indeed work with TrueType fonts, as we’ll explain in this Daily Drill Down. The bad news? It takes a bit of work to set things up, but you’ll find that it’s well worth the trouble. Although we’ll focus on the StarOffice angle, we’ll offer a brief overview of the TrueType configuration process for Red Hat and Mandrake systems. You’ll learn how to convert TrueType fonts to Type 1 printer fonts so that StarOffice can print and display them. In case you’ve had trouble getting TrueType support to work on your system, we’ll conclude by showing you how to convert TrueType fonts into the Type 1 fonts that any current X server can display without difficulty.

The usual caveats: The various fixes and workarounds that we provide aren’t officially supported by Sun, and they might stop working if you install a new version of StarOffice. The steps discussed here work with the currently distributed version, StarOffice 5.1a (available from the SunMicrosystems Web site). Also, please note that we’re assuming that you’re using a PostScript-compatible printer. If you’re using a non-PostScript printer, you’ll need to bring GhostScript into the picture—and that’s a subject we don’t have room to address in this Daily Drill Down.

What’s involved—and why isn’t this easy?
The answer to both of these questions begins with just one word—heck, just one letter—X.

As you’ve learned in “The StarOffice font deuglification project, part 1: Adding Type 1 (PostScript) fonts ” and “The StarOffice font deuglification project, part 2: Displaying smart quotes in imported Word documents ,” the X Window System can display fonts on-screen, but it does absolutely nothing to facilitate print output. That’s fine for applications in which you’re viewing the output on-screen, but it’s decidedly not okay for an office suite—or for that matter, any other application that requires high-quality output. Like AbiWord and Gnumeric, StarOffice addresses this problem by ignoring the X server’s list of available fonts and working only with the program’s list of printable fonts.

So, here’s the problem: You can configure X to fling TrueType fonts around on your display, but there’s no way to print them. As a result, StarWriter will ignore any TrueType fonts that you’ve installed.

Happily, there’s a workaround. The trick lies in converting copies of your TrueType fonts into Type 1 printer fonts and then installing these fonts in StarOffice. Once you’ve done so, you’ll see the fonts on-screen within StarWriter. What’s more, you can print them, and the printouts look pretty good. Note, however, that the conversion process wipes out the hints provided with TrueType fonts. In short, these hints provide information that enables the printer to do a good job with small fonts sizes (less than 10 points). If you need to print with small font sizes, you may notice that the output doesn’t look quite as good as the output produced by Windows or Mac systems. With normal and large fonts sizes, you’ll probably never notice the difference.

Caution: The Daily Drill Down “The StarOffice font deuglification project, part 2: Displaying smart quotes in imported Word documents” showed you how to modify the default Microsoft Word fonts (Times New Roman, Arial, and Symbol) so that StarOffice could display the smart quotes and other special characters in Word documents. If you modified these fonts as described in part 2, do not install the TrueType versions of these fonts.

Shopping list
You’ll need some TrueType fonts, of course, and a couple of utilities for the procedures discussed in this Daily Drill Down:

  • TrueType fonts—If you aren’t running Windows 98, you can obtain the basic TrueType fonts from Microsoft’s Typography Web site . In addition, sites all over the Web make TrueType fonts available for free.
  • ttmkfdir—This essential utility scans a directory for TrueType files and produces the fonts.scale file that the X font server (xfs) needs in order to display the fonts. If you don’t have the utility on your system, you can download it.
  • TrueType to Type 1 converter—The utility of choice is ttf2pt1, available from “TTF2PT1—A TrueType to PostScript Type 1 Converter .” Download and install ttf2pt1 so that you can execute the program from any directory.

Configuring your system for TrueType support
Since we’re addressing TrueType fonts in StarOffice in this Daily Drill Down, we won’t discuss the ways to get TrueType running on all Linux distributions. However, if you’re using Red Hat 6.0 or 6.1 (or derivatives like Mandrake), you can implement TrueType support easily. The process is so easy that we can describe the steps here briefly. For other distributions, you’ll need to obtain and install a TrueType-capable font server. Your choices are xfsft (which serves all X fonts and TrueType fonts) and xfstt (which serves only TrueType fonts). For more information on the latter option, see “The (preliminary) TrueType HOWTO .”

The following instructions work for Red Hat 6.0 and 6.1 and should work for Mandrake 6.0 and 6.1, too:

  1. Log on as root user, open a terminal window, and create a directory for your TrueType fonts (mkdir /usr/share/fonts/truetype).
  2. Copy the TrueType fonts to this directory.
  3. If necessary, convert the fonts to lower case. You can use the following simple shell script for this purpose, pressing [Enter] after each line:
    $for file in *.TTF
    name=$(echo $file | tr A-Z a-z)
    mv $file $name
    To use this shell script, type the first line (for file in *.TTF) and press [Enter]. Be sure to press [Enter] after you type each line.
  4. Important: If you previously modified and installed any TrueType fonts to display Word’s smart quotes correctly within StarOffice (as discussed in part 2 of this series), remove these fonts and any of their variants from the directory that you just created (/usr/share/fonts/truetype). StarOffice will crash if it encounters a font mapped to its screen that’s displayed both by a TrueType font and by a *.pfa file. If you followed the instructions in part 2 of this series and installed and modified Times New Roman, Arial, and Symbol, for example, remove these three fonts (including their bold and italic variants, if any) from this directory.
  5. In /usr/share/fonts/truetype, type ttkmkfdir > fonts.scale and press [Enter].
  6. Type mkfontdir and press [Enter].
  7. Tell the X font server where the new font directory is located. Start your favorite text editor and open /etc/X11/fs/config (for systems that serve fonts with xfs).
  8. Add the directory that you just created to the catalogue area of /etc/X11/fs/config. Carefully type the directory name on its own line and type a trailing comma (unless the directory you’re adding is the last in the list). Save the file and exit the editor.
  9. Restart the font server by typing /etc/rc.d/init.d/xfs restart and pressing [Enter].
  10. To make sure that you’ve added the TrueType font directory correctly, type chkfontpath and press [Enter]. Make sure that the directory you’ve added is present on the list.

Converting TrueType fonts to Type 1 fonts
The next step involves converting the TrueType fonts (the ones that you’ve installed in /usr/share/fonts/truetype) to Type 1 fonts (*.pfb and *.afm), so that you can install them in StarOffice. These fonts are used for printing, not on-screen viewing.

  1. Log in with your ordinary user account. Do not perform the following actions as superuser.
  2. In the StarOffice font directory, create a new subdirectory called truetype. To do so, open a terminal window, switch to the StarOffice font directory, type mkdir truetype, and press [Enter]. Switch to the directory that you just created by typing cd followed by the directory’s path name (such as /home/linda/Office51/fonts/truetype).
  3. Copy the truetype files to the directory that you just created. To do so, type cp /usr/share/fonts/truetype/*.ttf followed by a period (which represents the current directory).
  4. Use the ttf2pt1 utility to create *.afm and *.pfb (Type 1) versions of your TrueType fonts. To do so, type ttf2pt1 followed by the name of the first file (such as baskerville.ttf) and the first part of the font’s filename, as in ttf2pt1 baskerville.ttf baskerville. Instead of typing this command for each font, you can use the following shell script:
    $for file in *.ttf
    name=$(basename $file .ttf)
    ttf2pt1 -b $file $name
  5. Switch to the Office51/bin directory, type ./spadmin, and press [Enter]. You’ll see the Printer Installation dialog box.
  6. Click Add Fonts to open the Font Path dialog box.
  7. Click Browse to open the Select Directory dialog box.
  8. In the Directory text box, type the full pathname of the new fonts directory (such as /home/linda/Office51/fonts/msfonts). Alternatively, use the directory navigation window to locate and select this directory.
  9. Click OK. You’ll see the directory you’ve selected in the Font Path dialog box.
  10. Click OK to close the Font Path dialog box. The utility scans for new fonts and displays them in a list. Click OK to install these fonts. Next, you’ll see a dialog box informing you—incorrectly—that the new font directories will be added to the default X font path. Click OK to dismiss this dialog box.
  11. Important: Click Edit Font Attributes. You can’t print with the fonts that you’ve added until you’ve converted all the metric files for printing purposes.
  12. In the Fonts dialog box, click Convert All Metric Files.
  13. Click Close until you see the terminal window again.
  14. Restart X.

After you start StarOffice and open a new text document, you should see the TrueType fonts on the program’s font menus. If StarOffice crashes, make sure that you aren’t feeding the same font to the program in two different ways. For example, StarOffice will suffer an unrecoverable error if the X font server is supplying both a *.pfa and a *.ttf version of a given font, such as Arial, and you choose this font within your StarOffice document.

Installing additional TrueType fonts
Now that you’ve installed TrueType support, you’ll surely like what you see. Try creating and printing a StarImpress presentation with TrueType fonts. Chances are that you’ll want to install more TrueType fonts. To do so, follow these instructions:

  1. Log in as root user.
  2. Copy the new TrueType fonts to the /usr/share/fonts/truetype directory and make sure that their names are in lowercase letters only.
  3. Type ttkmkfdir > fonts.scale and press [Enter].
  4. Type mkfontdir and press [Enter].
  5. Type /etc/rc.d/init.d/xfs restart and press [Enter].
  6. Log in to the ordinary user account that runs StarOffice.
  7. Copy the fonts that you installed to the Office51/fonts/truetype directory; then, copy the fonts that you just installed.
  8. Type ttf2pt1 -b followed by the full name of the font file and the first part of the font’s filename (for example, ttfspt1 rage.ttf rage) and press [Enter].
  9. Repeat Step 8 for all of the new fonts that you’ve installed.
  10. Add the fonts to StarOffice by following steps 5 through 14 of the previous section (“Converting TrueType fonts to Type 1 fonts” above).

Using TrueType fonts without a TrueType-capable font server
If you’ve had no luck in getting a TrueType font server to work on your Linux system, don’t despair—you can still display and print TrueType fonts. The trick lies in converting all of them to Type 1 fonts. Here’s how:

  1. Log in with the user account that normally runs StarOffice.
  2. Within the StarOffice fonts directory (Office51/fonts), create a new directory called tt-type1.
  3. To this directory (Office51/fonts/tt-type1), copy all of the TrueType fonts that you want to convert to this directory.
  4. If necessary, convert the filename fonts to lower case. See step 3 of “Configuring your system for TrueType support” above for a simple script that will pull off this trick.
  5. First, using ttf2pt1’s -b switch, make the *.afm and *.pfb files. For a script, see step 4 of “Converting TrueType Fonts to Type 1” above.
  6. Add the *.afm and *.pfb fonts to StarOffice by following steps 5 through 14 of “Converting TrueType Fonts to Type 1 Fonts” above.
  7. Log out. Then, log in again as root user.
  8. Make a directory called /usr/share/fonts/tt-type1.
  9. Copy the TrueType fonts to /usr/share/fonts/tt-type1.
  10. Use ttf2ptl with the -e switch to make *.afm and *.pfa files that the X server can use. To do so, you can use this simple shell script:
    $for file in *.ttf
    name=$(basename $file .ttf)
    ttf2pt1 -e $file $name
  11. In the /usr/share/fonts/tt-type1 directory, type type1inst and press [Enter].
  12. In the same directory, type mkfontdir and press [Enter].
  13. Tell the X server or X font server where the new font directory is located. Start your favorite text editor and open /etc/X11/XF86Config (for systems that serve fonts with the X server) or /etc/X11/fs/config (for systems that serve fonts with xfs).
  14. Add the directory that you just created to the appropriate area (the FontPath area of XF86Config or the catalogue area of /etc/X11/fs/config). Carefully type the directory name on its own line and type a trailing comma (unless the directory you’re adding is the last in the list). Save the file and exit the editor.
  15. Restart X.

That’s it for StarOffice fonts! If you’ve stuck with me through this and the previous two Daily Drill Downs in this series, you’ve configured StarOffice so that it’s sure to please users who need to create good-looking presentations, print with nice-looking fonts, and exchange documents with Microsoft Word users.

Bryan Pfaffenberger, a UNIX user since 1985, is a University of Virginia professor, an author, and a passionate advocate of Linux and open source software. A Linux Journal columnist, his recent Linux-related books include Linux Clearly Explained (Morgan-Kaufmann) and Mastering Gnome (Sybex; in press). His hobbies include messing around with his home LAN and sailing the southern Chesapeake Bay. He lives in Charlottesville, VA. If you’d like to contact Bryan, send him an e-mail .

The authors and editors have taken care in preparation of the content contained herein, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.