Installing a TrueType font, step by step - Old Content

From Wiki
Revision as of 18:47, 28 April 2005 by Ville (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Background

I wanted to install the very fine Gentium font to my computer. The font is a free font with a very wide collection of latin and greek glyphs (cyrillic to come later). It can be downloaded from the SIL home page: http://www.sil.org/ .

While the font system is rather elegant and can be tweaked every possible way, it is difficult to get started with. For a beginner, new fonts may feel extremely difficult to install.

There are several good introductions to the subject. This is not one of those, as I am not going to tell a word about why or what. This is just a description of how I managed to install a new font. The process is surprisingly easy if it goes smoothly. If it doesn't, then I cannot help... If you want to stay out of trouble, please test your ConTeXt installation before installing the fonts. If it doesn't work before, it won't after.

My installation is a rather recent gwTeX (31 Jan 05) on Mac OS X with a ConTeXt installation from the same date. As the distribution is based on TeX Live, I guess the instructions given here should be rather universal. I am sorry, but the instructions give all the commands in the Unix form, so Windows users have to adapt. I try to give some hints to Windows and Linux users, as well, but everything is untested.

Procedure

First the font has to be downloaded somehow. This is system-specific, but in OS X the .sit file is downloaded and then installed by double-clicking it. It should be noted that for a non-priviledged user the font collection is installed into /Users/username/Library/Fonts/ folder. It is not necessary to install the fonts into the system, the packaged font collections can be used as such.

A slight problem arises from the fact that even though the font itself is a TrueType font (.ttf) file, it is visible as a collection of fonts (no file extension). This can be solved by a small utility called fondu. The utility comes with OpenOffice or can be downloaded from http://fondu.sourceforge.net/ . Using the utility is very simple: just type the path to the font to be converted: fondu /Users/username/Library/Fonts/Gentium and you will get a couple of ttf files in the current working directory.

At this point it is wise to make a temporary directory somewhere. If you do not know where, go and make a directory under /tmp, for example /tmp/work. There is no magic in the directory name, anything goes.

The life is slightly easier for Windows users, as the fonts are distributed as zipped .ttf</tf> files. (Of course, nothing prevents OS X and Linux users from using that package). Just unzipping the packet will do. Of course, don't forget to double-click the files if the fonts are to be installed into the system, as well. TeX could not care less if you install the fonts to your operating system, it is really up to you if you want to use them with other applications. These two installations are completely independent things.

Now we have a nice temporary directory somewhere and a few .ttf files in it. Then the actual font installation goes with a magic command (read on, if you want to avoid some pitfalls with file permissions):

texfont --ve=sil --co=gentium --makepath --install

This tells the wonderful texfont script to process all the .ttf files in the directory (you can limit the choice by supplying file names to the end of the command). The vendor of the fonts is sil and the name for the font collection is gentium. Again, there is no magic in these names, they are just used as directory names in the texmf tree. However, using just anything will make administration harder later on, so try to stick to reality.

The last two switches tell the script to make all missing directories and install the actual .ttf files to the right place in the texmf tree. In my case everything was installed into the local tree (/usr/local/teTex/share/texmf.local/...).

Beware, you will need administrative priviledges (power user, administrator, root) to be able to change the texmf tree. On Unix/Linux/OS X systems you can either log in as root which is not a good idea in general or use sudo. In OS X and other sudo-aware operating systems the following will work for all power users:

sudo texfont --ve=sil --co=gentium --makepath --install

Note that the passwword asked at this point is your password, not the root password.

In Windows, you should log in as a Power User (Administrator, whatever, different names in different versions of Windows). Otherwise you will end up with permission conflicts.

If you manage to get to this point and texfont does not complain much, the fonts are installed!

Testing the fonts

One of the nicest features in texfont is that it produces a test file. In this case the file is called texnansi-sil-gentium.tex. This file can be run by texexec --pdf texnansi-sil-gentium.tex. It will take a while especially with the Gentium font, but the result will be a few pages of glyphs.