Using TrueType fonts with pdflatex/livetex on Mac OS X
My University recently established a set of typographic conventions to be used when producing official documents such as presentations. A Powerpoint template was provided, but that was almost useless to me because I’m more a LaTeX guy. Aiming at building a beamer template compliant with the above conventions, I had to learn how to typeset LaTeX documents using the Trebuchet font in Mac OS X Mavericks equipped with pdflatex and livetex 2014. The steps I took should be independent
- of the specific operating system,
- of the livetex release, and
- of the chosen font, as soon as it belongs to the TrueType family.
First of all, it is advisable to create a temporary directory within which building the font files:
The following step consists in finding the TrueType descriptions of the chosen
font. This is easy for Mac users, as the corresponding files are shipped with
the OS in the /Library/Fonts
directory. For a given font there are typically
four descriptions, respectively for the standard form and the bold, italic and
bold+italic variants. The corresponding files have a name made up of the font
name, the considered variant and a ttf
extension. Such files should be copied
to our temporary directory, taking care of removing spaces in file names and
possibily adhering to the convention of adding the suffix “b”, “i”, and “z” for
the bold, italic, and bold+italic variants:
Next, we need to find out where three specific tex-aware directory are within
the file system. In order to find out the exact pathnames, which are dependent
on the specific texlive release, we can use the kpsewhich
utility and set up
three environment variables to be used henceforth:
In order to get the metric files for the font to be installed, we need to build
some intermediate files, encoded in the adobe font metric format, through the
ttf2afm
utility:
Note that the T1-WGL4.enc
encoding table could contain definitions for glyps
not included in the font we are installing: in such case, one or more warnings
(such as "glyph `ffl' not found"
) show up in stderr.
The .afm files can now be used in order to produce the font metrics which
texlive expects (...
means a skipped verbose output):
Now that Trutype and font metric files have been generated, we also need to create directories to hold them:
We are now ready to place all built files where texlive expects them to be.
Note that $TEXMFDIST
will typically point to a system directory, and in this
case you will need to get access to it (likely through sudo
):
To let texlive aware of the new font it is sufficient to add the following
lines at the end of $TEXMFSYSVAR/fonts/map/pdftex/updmap/pdftex.map
(again,
to be likely accessed through sudo
):
The last step consists in invoking the mktexlsr
utility, which builds a
database of files found in specific texlive directories:
To access the new fonts from LaTeX, a new style file has to be created.
Although other options are possible, this file typically has the same name of
the installed font, and is located in the tex/latex
directory under the user
texmf tree: thus edit $TEXMFHOME/tex/latex/trebuchet.sty
as follows:
To test that the installation is fine create a simple LaTeX document using
the trebuchet
package, such as the following one:
and pdflatex
it to check that no errors rise up and that the produced PDF
actually contains the new font (either visually or through an utility such as
pdffonts
). Finally, remember to clean up things by simply removing the
temporary directory:
blog comments powered by Disqus