|
Project: Linux Articles
True Type fonts under Linux
By Mayank Sarup <mayank@freeos.com>
Posted: ( 2000-10-03 12:10:17 EST by )
Linux may boast of having several fantastic GUIs but the fact remains that
when you get online, you do have to strain to look at the text on the screen.
Linux font support has lagged behind in the past but not now. Here's how you
can use True Type fonts under Linux.
It's time to get on the Internet. You fire up Netscape, go to www.freeos.com and look in horror at the horrible fonts in use. FreeOS obviously doesn't know how to make a good page. You move off to your other favourite news site and more horrendous fonts are waiting for you there too. Something wrong? Not really. Just that X doesn't use the newer True Type fonts which are now heavily used on the web and thanks to Microsoft, have become the most popular font format. X still uses the older bitmap fonts which don't scale well, hence the horrible fonts. Fortunately there is a way to utilise True Type fonts on Linux too. Xfree86 4 and above include True Type font support so you don't have to do anything else. If you're using a version below 4, you need to get a X true type font server. I'm using xfsft which you can get here. ( http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/ ). Currently it is the best font server and was made part of the Xfree86 4 source tree. The latest version as of writing this article is 1.1.6. Red Hat, Mandrake and users of distributions based on Red Hat do not need xfs as it is already included in versions later than 6, though slighthly modified. You can safely skip the next few steps. Untar the file somewhere. /tmp is a good location. tar zxvf xfsft-1.1.6.linux-i386-libc6.tar.gz cd xfsft-1.1.6 Copy the xfs binary to some suitable location. If you have a xfs binary lying somewhere then overwrite it with this one. I'm using SuSE and I copied this one over the one on my hard drive. cp xfs /usr/X11R6/bin/xfs Untar the included encodings.tar file in some suitable location, usually /usr/X11R6/lib/X11/fonts. cd /usr/X11R6/lib/X11/fonts tar xvf /encodings.tar Red Hat users can join me now. Create a new directory to hold your fonts. mkdir /usr/X11R6/lib/X11/fonts/ttf Where to get the fonts from? 1. There are plenty of free fonts on the Internet that you can download. Start with www.freefonts.com. 2. If you have a windows partition on your computer then you can use the fonts directly from the windowsfonts directory. Just mount the windows partition and add the font's directory to the FontPath in your xfs config or in you XF86config file. More on this later. You need to create a fonts.dir file that lists the fonts in your directory. You will need the ttmkdir utility which you can get here ( http://www.darmstadt.gmd.de/~pommnitz/TrueType/ttmkfdir.tar.gz ). Red Hat 6 and above already include this utility. Untar the tar.gz tar zxvf ttmkfdir.tar.gz cd ttmkfdir cp ttmkfdir.linuxbin.glibc2 /usr/bin/ttmkfdir Go to the directory where you placed the fonts. cd /usr/X11R6/lib/X11/fonts/ttf Run ttkmkfdir with the following command. ttmkfdir -o fonts.dir In Red Hat you can give the following command to add the True Type fonts directory to your list of font paths and restart the X font server. chkfontpath --add /usr/X11R6/lib/X11/fonts/ttf /etc/rc.d/init.d/xfs restart That is all you need to do to get True Type fonts into Red Hat and Red Hat'ish distributions. Other distributions require a little more work before they can start using True Type fonts. Create a new file /etc/xfstf.conf with the following contents client-limit = 10 clone-self = off use-syslog = off error-file = /var/log/xfs.errors # in decipoints default-point-size = 120 # x,y default-resolutions = 100,100,75,75 catalogue = /usr/X11R6/lib/X11/fonts/ttf, /usr/X11R6/lib/X11/fonts/morettf, /usr/X11R6/lib/X11/fonts/evenmorettf The great thing about this font server is that it can serve fonts to remote clients too. Set up this font server on your network and you can serve fonts to everyone on it. Way better than individually configuring each computer. Red Hat, with an eye on security, has modified the font server so that it will serve fonts only to the local computer. You will need to make a few changes to allow xfs to serve fonts remotely. Edit /etc/rc.d/init.d/xfs Look for a line that says "daemon xfs -droppriv -daemon -port -1". Remove the -droppriv part and the -port part. Restart the font server and you're ready to serve fonts remotely. Let's move on to the various configuration options given here. Red Hat's xfs configuration file is /etc/X11/fs/config. Syntax is the same. client-limit = x The number of clients that the font server should serve fonts to. clone-self = off If the font server reached it's client limit then should it create a clone to serve more clients. Use 'on' here if you want his behaviour. use-syslog = off Whether the font server should send messages and errors to syslog. Better option is to dump all that in a seperate file using the option below. error-file = /foo/blah/xfs.errors The file to which warning and errors will be dumped. default-point-size = 120 The default point size in decipoints for fonts where this is not specified. default-resolutions = 100,100,75,75 Default resolutions supported by the font server in pixels per inch. Multiple resolutions are seperated by commas. catalogue = /usr/X11R6/lib/X11/fonts/ttf A list of the directories where fonts can be found. Seperate with commas but no comma after the last entry. Start xfs with xfs -config /etc/xfsft.conf & Now you need to tell your X server the location of the True Type fonts. Make the following entry in all the client machines that will be using the font server. The file to edit is XF86config. This will be found under /etc/XF86config for SuSE or under /etc/X11/XF86config for Red Hat users. Find the FontPath entries in the configuration file and add another line there. FontPath "tcp/foobar:7100" Replace foobar with the name of your server or the IP address of the server. Or enter localhost if the fontserver is running locally. Red Hat users will need to replace the entry unix/:-1 with the above. One thing you will have to be careful about. If the font server goes down on the server then X will refuse to start because it is not able to find the True Type fonts. Comment out the entry and X will work fine. Start your browser and check out a cleaner web. If all goes well then just add the next entry to your startup scripts or to the server's startup scripts depending on where you're running the font server. /usr/X11R6/bin/xfs -config /etc/xfstf.conf & That's all you need to do to use True Type fonts under Linux. But it's not all good news. Fonts under Linux do not look as good as under Windows. Windows also uses a technique called anti-aliasing which greatly improves the overall appearance of fonts, especially at larger font sizes. Support for that is in the making and the result is said to be even better than Windows. Check out www.freetype.org for more on this.
Other articles by Mayank Sarup
Current Rating: [ 7.16 / 10 ]
Number of Times Rated: [ 38 ]
|