Adding Fonts to TeX
Contents
Adding fonts to TeX
This wiki page describes how you can add your own fonts to use with TeX. The instructions will depend on the type of the font: whether it is available as a PostScript Type 1 font, as a TrueType font, or as a font written in MetaFont source form.
You will also need to decide whether to put the font files in a separate directory structure (specified below), or whether just to put the files in the directory you will be in when running TeX. The first option allows the fonts to be available to you regardless of what directory you are running TeX in, but it requires a bit more work to set up. It also leads to less clutter in the directory where you keep your TeX source files.
This wiki page only describes how to add fonts for use with the tex and pdftex commands (including variants amstex, latex, pdfamstex, and pdflatex). For adding fonts to XeTeX, see the XeTeX documentation. Note that Xe(La)TeX natively supports PostScript Type 1, TrueType, and OpenType fonts, so that installation of fonts for XeTeX is much easier than the methods described here for ordinary TeX.
Adding LaTeX Support for the Fonts
Often fonts will come with files used to add LaTeX support for the fonts. Usually these files end in .fd or .sty. They should be put in subdirectories of the directory texmf/tex/latex (or in your current directory if you are not using texmf).
Installing the fonts themselves
The main part of the procedure for installing the fonts depends on what format they are provided in: MetaFont, Type 1, or TrueType.
MetaFont Fonts
Fonts provided in MetaFont source form are easy to set up for TeX, since they are built using a tool that is part of the TeX system.
MetaFont font files generally have names ending in .mp. To install them, put them in a directory ~/texmf/fonts/source or some subdirectory of this directory (often fonts will be provided in a tar or zip file that indicates a preferred name for this subdirectory). After doing this, run the program
texhash
to enable TeX and auxiliary programs to find the newly installed files quickly.
If, instead, you choose to install the files in the current directory, then you can do so. In this case you don't need to run texhash.
To test your installation, see the section #Checking the Font Installation, below.
PostScript Type 1 Fonts
The procedure for PostScript fonts is a bit more complicated, since (with a few exceptions) PostScript fonts are not created as part of the TeX system. As a consequence of this, their characters occur in a different ordering than in TeX fonts.
This situation is remedied by the use of virtual fonts. This mechanism requires that there be (at least) two font names, one (such as ptmr8r) for the "raw" font and one or more (such as ptmr7t or ptmr8t) for the reencoded font.
Usually, PostScript fonts have been repackaged for TeX by someone else. In that case, you can find them on CTAN as a package, with the virtual fonts, etc., already provided. If this is the case, then you can install them by putting them into your texmf directory under the following subdirectories:
Extension | Directory |
---|---|
pfa, pfb, pfm | texmf/fonts/type1 |
afm | texmf/fonts/afm |
tfm | texmf/fonts/tfm |
vf | texmf/fonts/vf |
tfm | texmf/fonts/tfm |
map | texmf/fonts/map/dvips |
When installing a PostScript font package from CTAN, first thing to do is always to read the provided instructions (README files and whatever documentation is provided), and then check the provided ZIP archive before unpacking it, by listing its contents. A lot of font packages are prepared so that unpacking the ZIP archive at the root of the texmf tree places all the relevant files in proper locations, greatly simplifying the installation process. That, however, cannot be taken for granted, so listing the contents of the ZIP archive before unpacking should be always mandatory.
If the PostScript font has not been set up for TeX, then you should read the documentation for fontinst. You may also contact Mariusz Wodzicki or Paul Vojta for assistance.
After putting the files in the indicated places, run the command
texhash
Then, for each .map file, run the command
env TEXMFVAR=$HOME/texmf TEXMFCONFIG=$HOME/texmf updmap --enable Map=file.map
or
env TEXMFVAR=$HOME/texmf TEXMFCONFIG=$HOME/texmf updmap --enable MixedMap=file.map
Use the second command if and only if there are also MetaFont versions of the fonts referenced in the .map file (see the manual page for updmap.cfg).
If there are many .map files, instead of running the above updmap command for each of them, you can run just the one command
env TEXMFVAR=$HOME/texmf TEXMFCONFIG=$HOME/texmf updmap --edit
This will put you into a text editor, editing a file containing lines of the form "Map file.map" or "MixedMap file.map". You should add such a line for each map file you installed earlier. The rules for using MixedMap instead of Map are the same as before.
To test your installation, see the section #Checking the Font Installation, below.
TrueType Fonts
TrueType fonts are not well supported in TeX. However, if you wish to install them, see the web page Using TrueType fonts with TeX (LaTeX) and pdfTeX (pdfLaTeX). (But: have you tried using Xe(La)TeX instead?)
Checking the Font Installation
To check that the fonts were installed correctly, you can run the TeX file testfont, as the following example illustrates (this example uses the font punk10; things you type are printed in bold):
% tex testfont This is TeX, Version 3.141592 (Web2C 7.5.6) (/usr/local/texmf/tex/plain/base/testfont.tex Name of the font to test = punk10 [Many lines of output omitted here] Now type a test command (\help for help):) *\table\bye [1] Output written on testfont.dvi (1 page, 5876 bytes). Transcript written on testfont.log.
You can then test the file by viewing it with xdvi or printing it with dvips. Or, (depending on the type of font file) you can use pdftex in place of tex and use a pdf viewer.