TrueType fonts, SuSE Linux 8.1 and KDE.

Persuading SuSE Linux (version 8.1) and KDE 3.1.x to co-operate in the use of TrueType fonts.

While using OpenOffice and Opera, both running under KDE and SuSE Linux, I had for a long time put-up with some fonts that really didn't look very nice. Eventually I found some time for research and discovered that bringing some TrueType fonts into use was not actually very difficult. In fact, when I came to repeat the process on subsequent computers, it only took about five minutes per computer.

Content revision history:
  • Article first written, August 2004
  • Content regarding KDE font configuration added 9th September 2004
  • Ammended 11th September when I realised that I had been confused about the procedure with SuSE Linux 9.0. The SuSE 9.0 procedure is now in another article.
  • Updated 14th August 2010 to incorporate a sensible script improvement offered by Gary Hoberg.

Acknowledgements

Almost always, somebody has been there before you and solved at least part of whatever problem you are now having. In my case a source of much useful information (on 6th July 2004) was found at The Linux Documentation Project: en.tldp.org/HOWTO/FDU/truetype.html. Most of the help I needed was found from the afore referenced page.

Preamble

Note, this article discusses what I had to do to get TrueType fonts working on a system on which SuSE Linux 8.1 had been installed. Other versions of SuSE Linux had slightly different procedures:

Making TrueType fonts work with SuSE Linux 9.0

Making TrueType fonts work with SuSE 9.2 (very easy).

Step 1: Create a directory containing the TrueType font files.

The directory that is going to contain the TrueType fonts must be permanently available while the X graphics system is running. Let us imagine that the directory is called /usr/TrueTypeFonts. Of course, you can call it something else if that is more convenient — just don't forget what you call it!

Step 2: Copy the TrueType font files.

Copy the .TTF files for the required TrueType fonts to the directory you just created. After copying the files, make sure that their file permissions are set to allow read access by anybody.

Step 3: Update the XFree86 configuration file.

In order to have X-Windows, and hence KDE, use the TrueType fonts that we need to inform the X-Windows system where those fonts are being held. This can be done by modifying the XFree86 configuration file. On my SuSE Linux 8.1 system the configuration file is located at: /etc/X11/XF86Config

In this file it is necessary to add a reference to the font directory that has just been created. A line should be added in the “fonts” section:

FontPath  "/usr/TrueTypeFonts"

I put this line in at the beginning of the “fonts” section — ahead of all the other FontPath lines. Of course, if you put the fonts in a different directory then you should make reference to whatever directory you chose to use.

Step 4: Create a script file to do some of the dirty work

It is necessary to convert all the file names to lower case and to remove any space characters that the names contain. If any file names contain spaces then you will have to rename them by hand, unless you have a clever program to do it for you. However you might be happy to know that the following script will perform the tedious job of converting all the names to lower-case. The script also will create two other files that the X-Windows system needs before it will use the fonts.

Create an executable text file containing the following script:

#!/bin/sh
 #
 ## -------- convert upper to lower case ---------
 
 ls * | while read f
  do
    if [ -f "$f" ]; then
      if [ "$f" != "`echo \"$f\" | tr A-Z a-z`" ]; then
       #Note that 'This' will overwrite 'this'!
       mv -iv "$f" "`echo \"$f\" | tr A-Z a-z`"
      fi
    fi
  done
 
# Note the punctuation -- the backquotes are
# important!  Remove any spaces from font names
# too.
# ----------------------


# Once the TrueType fonts are properly
# installed, you must create both fonts.dir
# and fonts.scale files. The following commands
# do this:
# 
# If you have SuSE 8.x you might need to use
# the following command instead of using the
# mkfontscale command.

#ttmkfdir -o fonts.scale

# The ttmkfdir command is not included in SuSE 9.0
# so in that case you need to use the fontscale
# command instead.

mkfontscale

mkfontdir

# This script needs to be placed in the
# directory with the font files.  Give it a
# name with lower-case letters because it is
# going to rename itself to lower-case anyway.

# If, when you execute the script, it gives you
# some cryptic error message for line 7, to the
# effect of "binary operator expected" then it is
# likely that your file names contain spaces and 
# you have ommitted some double-quotes in the 
# script.

# (Thank you Gary Hoberg for pointing offering a
# useful improvement to the script originally 
# presented on this page)
 
# eof

Well, I don't suppose you really want to type that little lot do you? And even cutting and pasting can be a real nuisance sometimes so here is a link to a text file that contains the above script: text file with script. You still have a little work to do because you will still need to set the correct permission bits to make it executable and put it in the right place — don't just go rushing off to execute it wherever it happens to be because then bad things might happen.

Penguin reading C-programming book
There is nothing shameful about having to read the manual from time to time.

This script was created by copying two sections of information from the web site mentioned above and simply merging them into one script, then adding some extra comments and making a simple alteration for use with SuSE 9.0. It will convert all the font file names to lower case and then compile two necessary files. This script file must be placed in the directory that contains the font files and executed from there.

Attention: The script might need to be modified if you are not using SuSE 9.0 — the instructions are in the script itself so please check before you use it. If the ammendment is needed then running the script without the ammendment probably won't create a disaster, but neither will it get your fonts working ...

To save yourself a little puzzle later please note that the script file will rename everything in the directory, including itself, so you might as well give it the script lower-case name to start with. Also if you get a message that says something about a binary operator expected on line 7 then it is likely that your file names contain spaces and you have missed some of the double quotes in the script. File names that have spaces in them need to be double-quoted or they won't get renamed properly, or at all, and, depending on the actual name of the file, might cause other undesirable side effects. So, you get the idea I'm sure, either remove the spaces first or make sure you have placed all the double-quotes correctly.

Also please note that the programs used by the script might have extra options that are pertinent to your situation or requirements so you might do yourself a favour by finding and reading and any appropriate documentation.

Step 5: Ensure the necessary programs are installed.

Before I could execute the script with SuSE 8.1 it was necessary to use the SuSE YaST program to install the “ttmkfdir” program from the SuSE DVD/CDROM. However with SuSE 9.0 the “ttmkfdir” program isn't supplied at all so, instead, you need to use a program called “mkfontscale” which is supplied. The script knows about both of these programs but you will need to edit the script by hand to ensure that the program you are not using is commented out.

Step 6: Execute the script file

Well, if you have edited the script appropriately, put it in the right place and set the permission bits correctly then now you can go ahead and run the script just created. When it has completed its work all of the file names should have been changed to lower case. One possible problem is that if you had two files that have the same name with different cases (for example “penguin.ttf” and “PENGUIN.TTF”) then the script will not perform correctly. Make sure that each font is represented by only one TTF file.

Step 7: Start or restart the X-server.

If KDE is already running then the X-server can be restarted using Ctrl-Alt-Backspace. If it is not already running then it can be started from a shell prompt using the command init 5; it will probably be necessary to be logged in as root to do this.

Step 8: Everything works, or perhaps not.

At this stage my TrueType fonts were available for use. If further help is needed then refer to en.tldp.org/HOWTO/FDU/truetype.html or find some other helpful web document.

Step 9: Printing and applications

Printing

Since I was using a postscript printer (a Kyocera FS1700 with postscript option) I did not need to do any further work to get the fonts to print.

Opera web browser

The Opera browser needed to be told to start using some of the newly installed fonts.This was achieved through the “preferences” dialogue boxes, obtained from the pull down menus or by pressing ALT-P.

KDE

There does not appear to be a single control panel for all the KDE font requirements so two stages were needed:

KDE desk top icons: Right-click an empty part of the KDE desktop, choose the “configure desktop” option from the menu and then, when the configuration window opens, click the “desktop” icon and then choose the “appearance” panel. Inside this panel is the font setting for your icon titles.

KDE menus: Bringup the launcher menu (somewhat similar to the Windows “start” menu) and choose [preferences—look and feel—fonts]. This will show a window in which there are six font options for you to change.

Pertinent links

openSUSE
Purveyors of various distributions of GNU/Linux.
Opera
The fine web browser that was using horrid, ugly fonts until I installed the TrueType ones. Opera is available for Linux, Windows and some PDAs. It is also available in various languages.
Kyocera-Mita
Manufacturers of the least troublesome printer I ever owned. It has been working almost flawlessly with all of my DOS, Windows and Linux software since 1997.
XFree86 web site
This might be a good place to look for any documentation that you think you might need. The XFree documentation is moderately comprehensive and readable. If nothing else it might give you some clues about the questions you should be asking.
The KDE project website
A good place to begin, though perhaps not to end, your search for information about the KDE environment.

 

Navigation: (site map) learn linux home pagetechnical articles