Using TrueType fonts with TEX via Postscript Type1 format

Harald Harders (h.harders@tu-bs.de)

2003-10-31

Abstract:

This document describes how I have managed to use TrueType fonts with teTEX 1.0 under SuSE Linux 6.2.1 The way described in ``Using TrueType fonts with TEX (LATEX) and pdfTEX (pdfLATEX)'' [Rak] did work with MiKTEX, but I did not manage to use the fonts with teTEX.

Strictly speaking this document doesn't describe how to use TrueType fonts with teTEX but how to convert TrueType fonts to PostScript Type1 format which can be used with TEX.

The shown shell commands are unix style. Similar commands should also work under Windows. Please try yourself to find the according commands.

If I have made any errors or if you have a suggestion please mail it to me.

A PDF version is also available.


Contents

1 Disclaimer

This document is provides as is. I will not guarantee that the described conversion works and that it doesn't course any damage. I also will not give any support for problems doing the conversion. Please refer to the newsgroups, e.g., comp.text.tex or de.comp.text.tex. My email address is given to give feedback (suggestions, error reports), not for support.

I don't know if the shown conversion violates any copyrights.

2 Preparing the conversion

As an example I will show how to convert the font ``VAG Rounded BT'' which is part of Microsoft Windows 98 (tt0756m_.TTF).

First copy the fonts you want to convert into a temporary directory (e.g., a Windows disk is mounted on /dos/c):

$ mkdir ~/ttf
$ cp /dos/c/windows/fonts/tt0756m_.TTF ~/ttf
Then rename the files to a name conforming the fontname scheme by K. Berry [Ber99]. In this case the supplier is ``Bitstream'' (Filename b*******.ttf)2. The Shortcut for the typeface is ``vr'' (Filename *vr*****.ttf) taken from [Ber99]. The weight is ``regular'' (Filename ***r****.ttf). The variant is omitted because itself and the width are normal. The encoding is set to ``8a'' which means Adobe standard encoding3 (Filename ****8a**.ttf). Because the width is standard and the font is linearly scaled, these parts of the filename are omitted. Finally the filename results in bvrr8a.ttf. Move the original file to this filename:
$ mv tt0756m_.TTF bvrr8a.ttf
A more detailed description on the naming conventions can be found in [Ber99].

3 Generating the Postscript Type1 fonts

To convert the TrueType font to Postscript Type1 format I used the program ttf2pt1 by Andrew Weeks et al. (http://ttf2pt1.sourceforge.net/). Generate the font files bvrr8a.afm, bvrr8a.pfa, and bvrr8a.pfb by using these commands:

$ ttf2pt1 -a -e bvrr8a.ttf bvrr8a
$ ttf2pt1 -a -b bvrr8a.ttf bvrr8a
The switch -a switches the conversion of some ligatures (e.g., fi) on (thanks to Hume Smith for that hint). In one of the last lines of the output the fontname is noted:
FontName VAGRoundedBT_Regular
Note the name on a sheet of paper--You will need it later again.

The script ttf2type1 does these conversion automaticaly for all files with the extension ttf in the present working directory. To get the font names you should start it as follows:

$ ./ttf2type1 2>&1 | grep FontName

4 Generating the TEX related font files

Use ``fontinst'' by Alan Jeffrey and Rowland McDonnell (ftp://ftp.tex.ac.uk/tex-archive/fonts/utilities/fontinst) to generate the files that TEX needs to use the fonts:

$ tex fontinst.sty
* \latinfamily{bvr}{} \bye
If you use fonts with different variants you have to append the letter of the variant to the family name of the font (e.g., VAGRoundedBT_Condensed would be bvrc). This automatic conversion only works if you are using a text font and if you have used file names according to the fontname scheme by K. Berry [Ber99]. Otherwise, you will get some nearly empty .fd files and nothing more.

Now use pltotf on every file with the extension .pl and vptovf on all files with the extension .vpl:

$ for a in *.pl; do pltotf $a; done
$ for a in *.vpl; do vptovf $a; done
Now you may delete all files that are not used anymore:
$ rm *.pl *.vpl *.mtx
The manual of the fontinst package includes a better description.

5 Move the files to the right places

Now all files have to be moved to a position where TEX can find them. I suggest to put them in the TEXMFLOCAL tree. One possibility to get its location is to view the file texmf.cnf. You can locate it by using kpsewhich:

$ kpsewhich texmf.cnf
e.g., on SuSE 6.2 and teTEX 1.0 texmf.cnf is located in the directory /etc/texmf/. Another possibility to get TEXMFLOCAL is to use kpsexpand:
$ kpsexpand '$TEXMFLOCAL'
On my computer the TEXMFLOCAL tree starts at /usr/local/teTeX/share/texmf.local. The TEXMFMAIN tree starts at /usr/local/teTeX/share/texmf. In order to have less work I set the shell variable TMF to the local TEX tree by typing:
$ export TMF=`kpsexpand '$TEXMFLOCAL'`

The files of each file type are installed in an own directory tree which has this structure:

$TMF/fonts/<extension>/<supplier>/<fontname>/
In this case:
$TMF/fonts/<extension>/bitstream/vagrounded/
The extensions are: tfm, vf, pfa, afm, and ttf. The extension pfb is an exception, its files have to be copied to the subdirectory .../type1/.... Copy the files by typing:
$ for a in tfm vf pfa afm ttf; do
> mkdirhier $TMF/fonts/$a/bitstream/vagrounded;
> mv *.$a $TMF/fonts/$a/bitstream/vagrounded;
> done
$ mkdirhier $TMF/fonts/type1/bitstream/vagrounded;
$ mv *.pfb $TMF/fonts/type1/bitstream/vagrounded;
You do not really need to copy the ttf and pfa files into the directory because TEX does not use them. I just did it to save them at a special place where I surely find them, if I need them for other purposes later.

Move the *.fd files to the directory $TMF/tex/latex/psnfss/:

$ mkdirhier $TMF/tex/latex/psnfss
$ mv *.fd $TMF/tex/latex/psnfss


6 Make dvips find the new font

There are at least two possibilities to make dvips find the new font. The first has a simple installation but it' usage is a little bit more complicated and it does not enable xdvi to use the font. The second possibility has a more complicated installation and may leed to problems when updating LATEX later. But it enables xdvi to use the new fonts.

6.1 Use an additional map file

Create the file $TMF/dvips/vagrounded/config.vagrounded with these contents:

o
p +vagrounded.map
Create the file $TMF/dvips/vagrounded/vagrounded.map with these contents (Each font definition is in one single line. So in this example each line starts with bvr and ends with <bvrr8a.pfb. ):
bvrr8r VAGRoundedBT_Regular "TeXBase1Encoding ReEncodeFont" <8r.enc <bvrr8a.pfb
bvrro8r VAGRoundedBT_Regular "0.167 SlantFont TeXBase1Encoding ReEncodeFont" <8r.enc <bvrr8a.pfb

The first item is the filename of the TrueType font with ``8r'' instead of ``8a''. The second item is the font name you held in mind, hopefully. The next items are the same all times. The last one is the filename of the TrueType font with the extension .pfb. Don't use the tabulator character in the mapping file because this causes trouble with the updmap tool generating the map file for pdfLATEX. Use one single space instead.

In the second line the slanted shape of the font is defined. The fontinst package generates slanted, italic and small capital shapes of the font automatically if no special font file is available. To use the generated slanted shape the second line is necessary.

Additional font effects can be reached by using afm2tfm. Type

$ info afm2tfm
and go to the section ``Special font effects'' (This was a hint of Thomas Henlich (henlich@mmers1.mw.tu-dresden.de)).

Finally type

$ texhash
to update the TEX file database.

6.2 Append data to the global map file

This technique was suggested by Nguyên-Dai Quż (daiquy.nguyen@ulg.ac.be) [Quý00]. There are different possibilities to append the map lines to the global map file. Here, only the simplest (and best) possibility is described. It works with all relativley recent teTEX versions.

Before you can do it the TEX file database has to be updated if that has not been done, yet:

$ texhash

Then, just type

$ updmap --enable Map vagrounded.map
If you have generated more than one map file you have to repeat that line for each map file. It is not possible to enable multiple map files in one call of updmap.

When you install a new version of teTEX probably the added map entries get lost. Then you have to repeat the updmap calls again.

7 Usage of the new font

To use the new font you simple have to insert

\renewcommand{\rmdefault}{bvr}\rmfamily
into you TEX sourcecode. For example sample.tex
\documentclass{article}
\begin{document}
\renewcommand{\rmdefault}{bvr}\rmfamily
\noindent Hello, I am VAG Rounded BT
{\slshape Hello, I am VAG Rounded BT slanted}\\
{\scshape Hello, I am VAG Rounded BT small capitals}\\
\end{document}
It is more elegant to create an new style file that switches to your new font. The style file vagrounded.sty is an example how this can be done.
\ProvidesPackage{vagrounded}
[2000/05/12 VAG-Rounded font as default sf font]
%%
\renewcommand{\sfdefault}{bvr}
%%
\AtEndDocument{\PackageWarningNoLine{vagrounded.sty}%
{Ensure to use dvips with the option -Pvagrounded}}
%%

If you have not included the mapping entries to the file psfonts.map (section 6) you also have to tell dvips that it should use the font:

$ latex sample
$ dvips -Pvagrounded sample
This should produce the PostScript file sample.ps which looks like figure 1.
Figure 1: Sample of the font VAGRounded BT
\includegraphics{sample_eps}

A. To do

Nguyên-Dai Quż has complained that the fontnames contain the underscore (_) instead of the minus (-). I have not been able to find out whether this causes problems using the fonts. But I also know that nobody uses fonts with an underscore in the name. So I should find out whether the underscores may cause problems e.g., when including eps files which use these fonts (e.g., from Adobe Illustrator).

B. Links

Nguyên-Dai Quý has written a script that does all or most of the conversion automatically [Quý00]. It is available from http://iris.ltas.ulg.ac.be/viettug/contrib/q/. This script also replaces the underscores by minuses in the fontnames.

Hume Smith has developed a method that does not include the Type1 fonts into the postscript file but tells ghostscript to use the TrueType fonts directly [Smi01]. He says that this approach avoids some problems with some fonts. But these files are not portable anymore because they do not contain the used fonts. His description is available from http://geocities.com/kwantus/ttf.html.

C. References

Bibliography

Ber99
K. Berry.
Fontname, March 1999.
ftp://ftp.dante.de/tex-archive/info/fontname/.

Quý00
Nguyên-Dai Quý.
Truetype with tetex : Quick and dirty, 2000.
http://iris.ltas.ulg.ac.be/viettug/contrib/q/.

Rak
Damir Rakityansky.
Using TrueType with TeX (LaTeX) and pdfTeX (pdfLaTeX).
http://www.radamir.com/tex/ttf-tex.htm.

Smi01
Hume Smith.
Kwantus' TTF/teTeX notes, 2001.
http://geocities.com/kwantus/ttf.html.

About this document ...

Using TrueType fonts with TEX via Postscript Type1 format

This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.70)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 0 -show_section_numbers -local_icons -no_navigation -image_type gif -dir html/ ttf-tetex

The translation was initiated by Harald Harders on 2003-10-31


Footnotes

... 6.2.1
The updmap section has been updated to teTEX 2.0.
... b*******.ttf)2
You can find this out by viewing the file with less.
... encoding3
Maybe the TrueType font is in Windows encoding, but the approach using ``8a'' worked fine, so I won't change it.


Harald Harders 2003-10-31