Using TrueType fonts with teTEX and dvips

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

2000-05-12

Abstract:

This document describes how I have managed to use TrueType fonts with teTEX 1.0 under SuSE Linux 6.2. 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 Type 1 format which can be used with TEX.

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

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

A postscript version and an acrobat reader version are also available.


Contents

1 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)1. 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 encoding2 (Filename ****8a**.ttf). Because the width is standard and the font is linearly scaled, these parts of the filename are omitted. Finaly 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].

2 Generating the Postscript Type 1 fonts

To convert the TrueType font to Postscript Type 1 format I used the program ttf2pt1 by Andrew Weeks et al. (http://www.netspace.net.au/~mheath/ttf2pt1/). Generate the font files bvrr8a.afm, bvrr8a.pfa, and bvrr8a.pfb by using these commands:

$ ttf2pt1 -e bvrr8a.ttf bvrr8a
$ ttf2pt1 -b bvrr8a.ttf bvrr8a
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

3 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). 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.

4 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/share/texmf. The TEXMFMAIN tree starts at /usr/share/texmf.

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

TEXMFLOCAL/fonts/<extension>/<supplier>/<fontname>/
In this case:
/usr/local/share/texmf/fonts/<extension>/bitstream/vagrounded/
The extensions are: tfm, vf, pfa, pfb, afm, and ttf. Copy the files by typing:
$ for a in tfm vf pfa pfb afm ttf; do
> mkdirhier /usr/local/share/texmf/fonts/$a/bitstream/vagrounded;
> mv *.$a /usr/local/share/texmf/fonts/$a/bitstream/vagrounded;
> done
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 be sure that they don't get lost, if I need them for other purposes later.

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

$ mkdirhier /usr/local/share/texmf/tex/latex/psnfss
$ mv *.fd /usr/local/share/texmf/tex/latex/psnfss


5 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.

5.1 Use an additional map file

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

o
p +vagrounded.map
Create the file TEXMFLOCAL/dvips/config/vagrounded.map with these contents (each font definition in one single line):
bvrr8r VAGRoundedBT_Regular
"TeXBase1Encoding ReEncodeFont" <8r.enc <bvrr8a.pfb bvrr8r 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.

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 tip of Thomas Henlich (mailto:henlich@mmers1.mw.tu-dresden.de)).

Finaly type

$ texhash
to update the TEX file database.

5.2 Append data to the global map file

This technique was suggested by Nguyên-Dai Quý (mailto:daiquy.nguyen@ulg.ac.be) [Quý00]. Here again two possibilities are available:

Finaly type

$ texhash
to update the TEX file database.

These solutions have one big problem. When you install a new version of teTEX probably the file TEXMFMAIN/dvips/config/psfonts.map will change so that your version TEXMFLOCAL/dvips/config/psfonts.map will be out of date. Then you will have to redo the procedure of the section.

6 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 [*]) 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 [*].

Figure: 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.q. 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.

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.

About this document ...

Using TrueType fonts with teTEX and dvips

This document was generated using the LaTeX2HTML translator Version 99.2beta6 (1.42)

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 -no_navigation -image_type gif -dir html/ ttf-tetex

The translation was initiated by Harald Harders on 2000-05-12


Footnotes

... b*******.ttf)1
You can find this out by viewing the file with less.
... encoding2
Maybe the TrueType font is in Windows encoding, but the approach using ``8a'' worked fine, so I won't change it.


Harald Harders 2000-05-12