Make your own free website on Tripod.com

TrueType Fonts on a Red Hat Linux 6.2 System

I run a Red Hat 6.2 system and I have decided that the default bitmap fonts just are not acceptable when viewing many web sites. The problem stems from the fact that many web sites are written with font specifications that require specific Microsoft TrueType fonts (e.g. Verdana, Arial and Comic Sans). Luckily enough some of these fonts are available from Microsoft's web site.

I decided to download the freely available "web" fonts from Microsoft's web site (available at: http://www.microsoft.com/typography/fontpack/default.htm). They are available in various formats. Download the ones that say they are for MS Windows 3.1. Even though they are in self extracting archives, you can use unzip to extract from the 16-bit executable meant for Win3.1.

As root, cd to /usr/share/fonts/default/ and create a directory called TrueType. Copy all of the TrueType fonts into this directory. Now cd into /usr/share/fonts/default/TrueType and run the program

 	bash# /usr/bin/ttmkfdir > fonts.scale
 

This will create the font information that xfs will require to use them. Now run the the command

 	/usr/X11R6/bin/mkfontdir 
 

or copy the fonts.scale file to fonts.dir in the same directory. Please note that you have to be in the /user/share/fonts/default/TrueType directory for ttmkfdir to properly create the fonts.scale file.

In the font server (or X server font-path section) configuration file find the catalogue section

 catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,
 	/usr/X11R6/lib/X11/fonts/75dpi:unscaled,
 	/usr/X11R6/lib/X11/fonts/100dpi:unscaled,
 	/usr/X11R6/lib/X11/fonts/misc,
 	/usr/X11R6/lib/X11/fonts/Type1,
 	/usr/X11R6/lib/X11/fonts/Speedo,
 	/usr/X11R6/lib/X11/fonts/compat,
 	/usr/X11R6/lib/X11/fonts/75dpi,
 	/usr/X11R6/lib/X11/fonts/100dpi,
 	/usr/share/fonts/default/TrueType,
 	/usr/share/fonts/default/Type1
 

and make sure the "/usr/share/fonts/default/TrueType," line is included. In Red Hat 6.2 this in the /etc/X11/fs/config file. Now you need to restart the font server with

 	bash# /etc/rc.d/init.d/xfs restart
 

These are all the changes needed on a Red Hat 6.2 system. If you are running a different distribution you will need to make other changes as well. You will also have to run the command

 	bash# usr/sbin/chkfontpath --add /usr/share/fonts/default/TrueType
 

so that the X server will know where to look for the new fonts.

Now restart the X font server (or X server if you are running an older/other distribution). I have only tested this on a Red Hat 6.1 and 6.2 system. If you install TrueType fonts on a different distribution, using this method, please send me an email with the details at pknezevich@home.com and I will include your observations, with credit of course.

You should now be have a pleasant time viewing web sites that ask for these fonts (restart Netscape to see changes). Also make sure you have the option

 	* Use document-specified fonts, including Dynamic Fonts
 

selected. It can be found under

 	Edit -> Preferences -> Appearance -> Fonts
 

If you have it set to use your own default fonts, Netscape will override the page specific fonts and you might have a difficult time viewing the sites page layout.

A good place to test these changes is at this http://www.microsoft.com/typography/css/gallery/slide2b.htm web site. Check out the various slides in this CSS demo.

There are more modifications that can be made to your system to change the appearance of the fonts in Netscape. You can view the Netscape.ad file to find many options and settings available, insert them in your ~/.Xdefaults file

 e.g.
 	Netscape*documentFonts.xResolution*iso-8859-1:    100
 	Netscape*documentFonts.yResolution*iso-8859-1:    100
 	Netscape*documentFonts.xResolution*iso-8859-2:    100
 	Netscape*documentFonts.yResolution*iso-8859-2:    100
 	Netscape*documentFonts.xResolution*windows-1250:  100
 	Netscape*documentFonts.yResolution*windows-1250:  100
 	
 ! There are 7 font sizes, 1 thru 7.  The default font is 3, and the others
 ! are based on this.  The default increment is 20%, which means that the 4
 ! is 20% larger than the 3, the 5 is 40% larger, and so on.
 	
 	Netscape*documentFonts.sizeIncrement:  20
 

You can also make other modifications in the /etc/X11/fs/config file like

 e.g.
 	# in 12 points, decipoints
 	#default-point-size = 120		# the default, but
 	default-point-size = 140		# I like them bigger
 

In the sample catalogue section above, you can see that there are duplicates of some lines with ":unscaled" appended to them. This tells the font server to use unscaled fonts by default instead of scaled fonts (most fonts don't scale well since they are bitmaps). If the 100dpi lines were above the 75dpi lines then the server would use the larger fonts first as well. You have to have installed the 100dpi fonts first. You can check to see if they are installed by running the command

 	bash# rpm -qi XFree86-100dpi-fonts
 

If they are installed you will see the rpm description.

There are many ways to modify the way the X server displays fonts. This is just the beginning.

The Short Cut

I have written a little perl script that will install the TrueType fonts on a Red Hat 6.2 system. In the directory where you have the script create a directory called "ttf". Place all the TrueType fonts you have in this directory. Now run the script and it will install the fonts, create the fonts.scale and fonts.dir files and restart the font server. The script has to be run as root.

Here is a copy of the script

 	#!/usr/bin/perl -w
 	
 	$ttf_dir = '/usr/share/fonts/default/TrueType';
 	
 	if(!(-e $ttf_dir)){
 	  mkdir($ttf_dir,0777) or die "mkdir failed: $!";
 	}
 	
 	@ttf_files = <ttf/*>;
 	!system("cp $ttf_files $ttf_dir/.") or die "external cp command status: $?";
 	!system("cd $ttf_dir; /usr/bin/ttmkfdir > $ttf_dir/fonts.scale")
 	         or die "system call /usr/bin/ttmkfdir status: $?";
 	!system("cp $ttf_dir/fonts.scale $ttf_dir/fonts.dir")
 	         or die "external cp command status: $?";
 	xfs_config();
 	!system("/etc/rc.d/init.d/xfs restart")
 	         or die "status on /etc/rc.d/init.d/xfs restart was: $?";
 	
 	sub xfs_config{
 	  $^I=".bak";				#in-place editting with back-up
 	  $ttf_line = "\t/usr/share/fonts/default/TrueType,";
 	  @ARGV = ("/etc/X11/fs/config");	#with $^I, sets print default to ARGVOUT
 	  while(<>){
 	    if(/catalogue =/){
 	      print;
 	      print "$ttf_line\n";
 	    } else {
 	      print;
 	    }
 	  }
 	}
 

Copy this into a file, make it executable and run it.

Copyright (C) 2001 Petar Knezevich

Disclaimer

Every attempt has been made to ensure that the information presented in this mini-HOWTO is safe and accurate. However, this information is given without any warranty, either expressed or implied, as to its suitability for a particular use. It is generally considered a GoodThing(TM) to make backups of your system files before changing system configurations and/or files. I suggest you take this precaution "just in case".