hackorama
hackorama
HOW TO USE TRUE TYPE FONTS (TTF) ON UNIX/LINUX

This note explains how to install and use truetype fonts on UNIX/LINUX machines running XWindow System. Explains how to get xfstt truetype font server for UNIX/LINUX/FREEBSD how to install, verify and run it along with how to install new ttf fonts.

DISCLAIMER: ALL STANDARD DISCLAIMERS APPLY, I AM NOT RESPONSIBLE FOR ANY DAMAGE TO YOUR MACHINE CAUSED BY FOLLOWING THE DIRECTIONS GIVEN ON THIS PAGE. USE THEM AT YOUR OWN RISK



1. Get xfstt the truetype font server

Since there are few variants of UNIX ( GNU Linux, FreeBSD, Solaris, IRIX, HP-UX, AIX ) The most common way of xfstt distribution is as source which you can build on your Unix variant platform using a C++ compiler.

If you don't have C++ compiler please search the FTP sites for an already built binary for your platforms. For Linux users there are binaries and rpm packages available at various sites.

But if you have a C++ compiler its pretty easy to build and install.

( Or better still download the GNU C++ compiler - GCC )

1. I have the following source/binary/rpm's for download ( might be slow )

xfstt-0.9.99.tar.gz ( source for any UNIX/GNU LINUX)

xfstt-0.9.99-1.i386.rpm ( rpm for LINUX libc6 )

xfstt-irix ( FOR IRIX 6.X ELF N32 MSB mips-3 dynamic executable )

2. A search on the web will hit up on many other download places too.

NOTE: these sites will have the latest versions, and distributions

for various platforms too.

3. The latest source distribution can be found at the following site. ( as of Sept. 1999 )

ftp://metalab.unc.edu/pub/Linux/X11/fonts/

( xfstt-0.9.99.tar.gz (85 Kb) / Xfstt-0.9.10.tgz (78 Kb) )



2. Notes on Building xfsst

You need a C++ compiler The default makefile uses C++ as the command line for invoking the C++ compiler front end This works fine for linux and some other Unix machines But on your Unix machine it may be called CC or egcs or g++ So Please change the makefile with the correct C++ compiler. ( Make sure to have a copy of the original make file before modifying it ) If you don't have a C++ compiler or its called something else make command will give you error message.

Just type make, and wait for the xfstt to build.



3. Notes on the binary distribution

Please follow the directions for each platform like rpms for linux Inst packages for IRIX ( Or you may have it as an ELF executable which can be just copied )



4. Installing xfstt

You need to be root to install, So if you dont have root access talk to your friendly sysadmin.

Even though the Makefile has on option to install xfstt by typing "make install" this may not work seamlessly on all UNIX variants. It works fine on Linux. All install does is create a directory for the font files and copies the xfstt binary to /usr/X11R6/bin/

You can either use "make install" or run the commands yourself from command line.

You have to be root to do the installation

If "make install" fails:

(1) Create the following directories at the given path

mkdir /usr/share/fonts/truetype

mkdir /var/cache/xfstt

( if the path does not exist create it )

(2) Copy the xfstt binary to the path

cp xfstt /usr/X11R6/bin/

( If you don't have the above path please copy it into one of the bin directory which is in path like /usr/bin /bin, /usr/local/bin or look for your X bin path like on IRIX at /usr/bin/X11 )



5. Running xfstt

1. First copy some ttf files to /usr/share/fonts/truetype

2. Now Let xfsst find the availabe fonts

"xfstt --sync"

If you have 7 fft files in /usr/share/fonts/truetype

you should get an output like

kishan@allmylove 1# xfstt --sync xfstt: sync in directory "/usr/share/fonts/truetype/." Found 7 fonts. kishan@allmylove 2#

3. Now start xfstt as a background process, type:

xfstt &

4. Now set the font path

xset fp+ unix/:7101

5. Test whether the fonts are available by running

either "xlsfonts" or "xfontsel"

or by going to the website which uses the font

or starting an application like gimp.



The runxfstt.sh - script

Here is runxfstt.sh a simple shell script I wrot Just modify the script to reflect the directory where you have xfstt. And dont forget to do a "chmod u+x" on the file.

#!/bin/sh echo " " echo "Script for running XFSTT Font Server" set dir # modify the dir path to reflect # where you copied xfstt dir='/usr/local/bin' echo " " echo "1.Cleanup" echo ">killall xfstt" killall xfstt echo ">xset fp- unix/:7101" xset fp- unix/:7101 echo " " echo "2.Sync the Fonts" echo ">$dir/xfstt --sync" $dir/xfstt --sync echo " " echo "3.Launch $dir/xfsst" echo ">$dir/xfstt &" $dir/xfstt & echo " " echo "4.Set Font Path" echo ">xset fp+ unix/:7101" xset fp+ unix/:7101 echo " "



6. Adding new fonts

Whenever you add a new ttf font.

All you have to do is copy the fonts to /usr/share/fonts/truetype and let xfstt know about it,

by running "xfstt --sync"

xfstt will pick up the new fonts.

But make sure xfstt is running:

kishan@allmylove 5# ps -ef | grep xfstt root 7787 7570 0 Sep 01 pts/4 0:07 xfstt kishan 12910 12764 0 17:51:43 pts/4 0:00 grep xfstt kishan@allmylove 6#



7. Running xfsst at bootup

Please put xfstt in the proper start up scripts depending on your UNIX platform, such that the font server will be running when X starts up. when ever you install a new ttf font just do a "xfstt --sync".

Or you can manually start xfstt following the procedure in Step 5 whenever you want to use the ttf fonts.



8. Stopping xfstt

For some reason if you want to stop the sfstt font server do a "killall xfstt" followed by a "xset fp- unix/:7101"

**** IMPORTANT **************************

WHEN xfstt IS NOT RUNNING

MAKE SURE YOU DO RUN:

xset fp- unix/:7101

**** IMPORTANT **************************



this is important since if the port is open and part of the font path applications might try to get fonts from the port and when xfstt is not running will wait on a loop to get the fonts!



9. More Info

There is a very good FAQ which comes with the source distribution and please do a search on the web to get lot of extra information and newsgroups discussions on xfstt.

The FAQ from xfstt-0.9.99



10. Notes

The distribution works without a hitch on linux other UNIX variants may have slight hitches like modifying the Makefile the file path to the fonts directory may not exist or will be different

If you have a directory full of ttf fonts you can make a link in /usr/share/fonts/truetype/ so that xfstt finds those fonts when you do a xfstt --sync

for example:

ln -s /path/to/fonts /usr/share/fonts/truetype/myfonts

ERRORS:

When you are running xset fp- unix/:7101 and if you get an

error like:

kishan@allmove 32# xset fp+ unix/:7101 xset: bad font path element (#47), possible causes are: Directory does not exist or has wrong permissions Directory missing fonts.dir Incorrect font server address or syntax

Do a: killall xfstt , xset fp- unix/:7101

Now start all over: xfstt --sync , xfstt &, xset fp+ unix/:7101



11. Techie notes for the paranoid

A word of warning: xfstt makes its fonts available to the X server on a port (default is 7100), so it has to be running for the fonts to be available to the server. If you're setting up xfstt to start automatically, be very careful about adding the path to that port (the default is 'unix/:7100') to your FontPath menu: if it should happen that xfstt doesn't manage to start before X tries to start, X will not start (and if you have xdm start up to manage logins, you may even find your display effectively deadlocked).

Read the FAQ included about ways to do this right. (Being somewhat paranoid, I suggest leaving xfstt's port out of the font path and starting xfstt with a script in, say, rc.local that first checks to see whether X is running and then adds xfstt to the path.)



Thursday, 29-Nov-2001 21:42:19 PST kishan at hackorama dot com