Jul 152000

True Type fonts and XFree86

Jim Weeks wrote in to tell us about true type fonts under X.  He told me about this back in May, but I’m only just getting around to posting the message.  Sorry.  And thanks Jim.

Note: I have made some changes to Jim’s text.  Any mistakes are therefore mostly likely mine.

Note: Previous versions of this article referred to port 7100, which is incorrect.   This mistake has been fixed by referring to port 7101 instead.

Installing the XfStt port

The following operation requires root access.

The easiest way to use TrueType (*.ttf) fonts in FreeBSD/XFree86 is to first install XfStt from the ports collection.  This port is found under X11-servers (/usr/ports/x11-servers/Xfstt/).   See Installing a port without installing the ports or Installing all the ports for more information about installing a port.  But in short, you do this:

cd /usr/ports/x11-servers/Xfstt/
make install

Getting the fonts

Once that port is installed, you need to create the directory /usr/X11R6/lib/X11/fonts/TrueType which is where XfStt looks for fonts.  Next, you should populate the directory with fonts.  TrueType (*.ttf) fonts are easily found and several are even available for download on the Microsoft web site.  One way to get the fonts is to zip the font directory on that old MS Windows machine before you reformat the drive for FreeBSD.   If you are lucky enough to have the old machine on a local network you may want to ftp the fonts over to your FreeBSD machine.

These are also good spots.


Check also the FAQ for xfstt for a list of sites (if you’ve done a make clean, you can get the FAQ back by doing this: .

tar zxvf /usr/ports/distfiles/xfstt-1.1.tar.gz xfstt-1.1/FAQ

Once you have the fonts in your new TrueType directory you are ready to start the server.

Starting the server

You can start it by simply typing "xfstt &" at the command prompt.   You should insure that xfstt is started at boot time.  This is easily accomplished by adding the following lines to a script in /usr/local/etc/rc.d.   Call the script xfstt.sh, and add the following lines:
[ -x /usr/X11R6/bin/xfstt ] && /usr/X11R6/bin/xfstt & && echo -n ' XFstt'

You may also wish to customize this script based upon the man xfstt page.

Font database synchronization

The font database will be synchronized the first time you start the server.  If you wish to add fonts later you will need to stop the server and type:
xfstt --sync

to re-synchronize the database.

Tell X all about it

The last thing you need to do is make Xfree86 recognize your new fonts.  In order to do this you will need to add the following line to your list of fonts in /etc/XF86Config:
FontPath "unix/:7101"

where "7101" is the default port for the native FreeBSD version of XfStt.   You should now be ready to start X and test your installation.

Checking that it’s all working…

If you have Netscape installed you can check under Edit/Preferences/Fonts.  The new fonts should now be visible in the Variable width fonts menu.

If you don’t have Netscape, you can always run xfontsel. And this will show you fonts as well:

xlsfonts | grep ttf | more

  4 Responses to “True Type fonts and XFree86”

  1. (written by Benedikt Schmidt but posted by Dan Langille)

    XFree86 4 has native support for True Type fonts and therefore you don’t need another font server like XfStt which is needed for older versions of X.

    There are many places to get TrueType fonts and some of them are described in an older FreeBSD Diary article called "True Type fonts and XFree86".

    Once you have all the fonts you want to install do the following as root:

    mkdir /usr/X11R6/lib/X11/fonts/TrueType
    cp *.ttf /usr/X11R6/lib/X11/fonts/TrueType

    After having copied all fonts to the right directory you have to create a fonts.dir file containing information about the fonts.

    cd /usr/port/x11-fonts/ttmkfdir && make install
    cd /usr/X11R6/lib/X11/fonts/TrueType && ttmkfdir > fonts.scale
    cd /usr/X11R6/lib/X11/fonts/TrueType && mkfontdir

    After that you just have to tell X to use the new fonts by adding two lines to /etc/X11/XF86Config.

    In Section "Module" you add:
    Load "freetype"
    And in Section "Files" you add:
    FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"

    Restart X and start up netscape or xfontsel to see if the new fonts are available.

    • //////URGRNT////

      I wanna simsun.ttf in mozilla,so

      mkdir /usr/X11R6/lib/X11/fonts/TrueType
      cp simsun.ttf /usr/X11R6/lib/X11/fonts/TrueType

      cd /usr/port/x11-fonts/ttmkfdir && make install
      cd /usr/X11R6/lib/X11/fonts/TrueType && ttmkfdir > fonts.scale

      !!! then ERROR: unkown font foudry code ZYEC !!!

      cd /usr/X11R6/lib/X11/fonts/TrueType && mkfontdir

      vi /etc/X11/XF86Config

      In Section "Module" add:
      Load "freetype"
      And in Section "Files" you add:
      FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"

      and when I startx,
      !!! ERROR:Fatal server error—
      cound not open default font ‘fixed’

      but when I del line "FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"
      then OK!

      whay shall I do!!

    • After I installed XFree86-4, I didn’t have to do this step:

      cd /usr/port/x11-fonts/ttmkfdir && make install

      It was already there.

    • im terribly new to freebsd, so this is probably not a difficult question. when i try to install ttmkfdir from the ports i get the following error:

      newly created file is older than distributed files!
      check your system clock

      ive got this error before and really dont have a clue on how to solve it. if you have time please help me out.