TEX (not LATEX) and type 1 fonts for UNIX

Step 1

Get the type 1 fonts. These are also referred to as PostScript fonts. For example, if the font is Salsa, you should get the following files:

  • Salsa.pfb : the binary format of the font file.
  • Salsa.pfa : the ascii format of the font file. This can be generated from the pfb file by tools in the t1utils package. Look for t1asm or pfb2pfa.
  • Salsa.afm : the metrics file. This comes with the font. It is an ascii file with character width and character positioning information.
  • Salsa.tfm : the metrics file that TEX requires. It can be generated by a variety of tools. The tool afm2tfm is on all UNIX systems.
Make sure that the base file name (Salsa in this case) is the same as the font's name. The font's name can be read from the FontName line in the pfa file via a "grep" command.

Step 2

Install the fonts. Make any directory of your choice for the "tfm" and "pfa" files. Assume you use /home/tfm for the "tfm" files and /home/pfa for the "pfa" files. You don't need the "afm" and "pfb" files any longer but do not throw them out--they may be useful in other applications.

Step 3

Tell TEX where the tfm files are. TEX only needs the tfm file. It does not require the font, as TEX only places empty boxes on a page. It just needs to know the sizes and placement of these boxes. We use an environment variable TEXFONTS set as follows:

     setenv TEXFONTS .:/home/tfm:other-directories-separated-by-colons
Make sure that all TFM directories are in this list. There should be TFM directories in the font area of your TEX fonts. Places like /usr/local/share/texmf/fonts/tfm or /usr/lib/texmf/fonts/cm/sauter/tfm. Check your computer for this. The "setenv" command can be given once, just before you "tex" a file, or it can be given in a startup file such as your .cshrc file (this is what I do).

Step 4

Tell dvips that you have the type 1 font. DVIPS, which is in charge of taking the TEX output, a dvi file, and replacing the empty boxes by actual characters from a font, among other things, needs to know that you are supplying the font. This is done through a file in your home directory, called ".dvipsrc". Mine looks like this:

   f
   M localfont
   m 6000000
   D 600
   R 100 120 144 300 360 400 432 480 600 648 720
   T .:/home/luc/tfm:/usr/local/share/texmf/fonts/tfm
   P .:/ps/tex/pk:/usr/local/share/texmf/fonts/pk
   H .:/usr/local/tex3.0/lib/ps
   p /home/luc/fontlist
Please don't copy this if you don't know what you are doing. The D line establishes the dpi of the printer (only needed if you use metafont--irrelevant for type 1 fonts). The R line gives the sizes of the bitmap fonts needed if metafont is fired up. Again, not needed for type 1, but it is safe to keep this line there. The T line gives the directories where tfm files may be found. The P line gives directories for the PK files (not needed for type 1). The p line finally gives a filename that has all the type 1 fonts. It lists one font name per line, as in
   cmr10
   Salsa
   Salsa-Outline
   Salsa-Italic
   Salsa-Swash
   Courier
You can place that file (in my case /home/luc/fontlist) anywhere.

Step 5

Within the TEX file. First, you need to set the various fonts to be used in your text. Here is an example declaration:

   \font\rm=GaramondRepriseSSi at 11pt
   \font\it=GaramondRepriseSSi-Italic at 11pt
   \font\bf=GaramondRepriseSSi-Bold at 11pt
   \font\bi=GaramondRepriseSSi-BoldItalic at 11pt
   \font\sc=GaramondRepriseSSi-SmallCaps at 11pt
   \font\osf=GaramondRepriseSSi-ItalicOldStyleFigures at 11pt
   \font\bsc=GaramondRepriseSSi-BoldSmallCaps at 11pt
   \font\bosf=GaramondRepriseSSi-BoldItalicOldStyleFigur at 11pt
   \font\mini=GaramondRepriseSSi at 10pt
This permits you to use, in the body of the text, phrases such as
   \rm
   One should {\it never} use {\bf bold} typefaces in running text,
   but use {\it italics} instead. Words like {\sc nasa} and
   {\sc cia} should be set in small caps, and dates such
   as {\osf 1999} are better set in old style figure fonts.


However, there is an adder in the grass. The characters in the font may not be in the right positions---a question of encoding. There are two solutions to this. The quick fix, for small documents, letters, one-time write-ups, when you are in a hurry, is to just define characters you want this way:

   \font\rm=PastonchiMT-Regular at 12pt
   \font\za=ZapfDingbats at 12pt
   \def\tel {{\za \%}}
   \def\finger {{\za +}}
   \def\nib {{\za 2}}
   \def\pen {{\za .}}
   \def\envelope  {{\za )}}
   \def\asterisk{{\rm \char42}}
   \def\dagger{{\rm \char178}}
   \def\ddagger{{\rm \char179}}

This defines \tel as the character corresponding to "%" in Zapf Dingbats, and \dagger to be the character in decimal position 42 of the font PastonchiMT-Regular. In running text, you write \tel\ and \dagger\, instead of the more cumbersome {\za \%} and {\rm \char42}. How do you know where the characters are in a font? Look at the pfa or afm file and look at the encoding vector. It's not hard to figure out the numerical positions of all the characters.

The more serious problem is that of a global fix, more long-term. Since so many fonts use so many different encodings, you have to be flexible. There is no magic bullet. I use the macro
   \adobe
before all font declarations, for example, when I am dealing with an Adobe or Bitstream font. The macro is given below, but use it at your own peril. Note the difference with the earlier solution: instead of using \tel or \dagger, we now use the original symbols in the text. The code below also fixes the positions of the accents. Symbols are referred to in the text by their names, such as \dagger.
   % Luc Devroye, November 10, 1994.
   %
   \def\adobe{%
   \chardef\ss='373% germandbls
   \chardef\quotesingle='251
   \chardef\exclamdown='241
   \chardef\questiondown='277
   \chardef\asciicircum='136
   \chardef\asciitilde='166
   \chardef\<=`<
   \chardef\>=`>
   \chardef\oe='372
   \chardef\oslash='371
   \chardef\AE='341
   \chardef\ae='361
   \chardef\OE='352
   \chardef\Oslash='351
   \chardef\cent='242
   \chardef\sterling='243
   \chardef\fraction='244
   \chardef\yen='245
   \chardef\florin='246
   % \chardef\section='247
   \chardef\currency='250
   \chardef\quotedblleft='252
   \chardef\guillemotleft='253
   \chardef\guilsinglleft='254
   \chardef\guilsinglright='255
   % \chardef\fi='256
   \chardef\fl='257
   \chardef\endash='261
   \chardef\dagger='262
   \chardef\daggerdbl='263
   \chardef\periodcentered='264
   \chardef\paragraph='266
   \chardef\bullet='267
   \chardef\quotesinglbase='270
   \chardef\quotedblbase='271
   \chardef\quotedblright='272
   \chardef\guillemotright='273
   \chardef\ellipsis='274
   \chardef\perthousand='275
   \chardef\ogonek='316
   \chardef\emdash='320
   \chardef\ordfeminine='343
   \chardef\Lslash='350
   \chardef\ordmasculine='353
   \chardef\dotlessi='365
   \chardef\i='365
   \chardef\lslash='370
   \chardef\asciitilde=`~
   \chardef\underscore=`_
   % 
   % 
   
   \def\emdash{{\char'320}}
   \def\endash{{\char'261}}
   \def\`##1{{\accent'301 ##1}}% grave
   \def\'##1{{\accent'302 ##1}}% acute
   \def\v##1{{\accent'317 ##1}}\let\^^_=\v% hacek
   \def\u##1{{\accent'306 ##1}}\let\^^S=\u% breve
   \def\^##1{{\accent'303 ##1}}\let\^^D=\^% circumflex
   \def\.##1{{\accent'307 ##1}}% dotaccent
   \def\H##1{{\accent'315 ##1}}% hungarumlaut 
   \def\~##1{{\accent'304 ##1}}% tilde
   \def\"##1{{\accent'310 ##1}}% dieresis
   \def\=##1{{\accent'305 ##1}}% macron
   \def\r##1{{\accent'312 ##1}}% ring
   % \def\^##1{{\accent195 ##1}} \let\^^D=\^
   \def\:##1{{\accent'310 ##1}}
   \def\c##1{\setbox\z@\hbox{##1}\ifdim\ht\z@=1ex\accent'313##1%
   \else{\ooalign{\hidewidth\char'313\hidewidth\crcr\unhbox\z@}}\fi} 
   % \def\c{\protect\pc}% cedilla
   \def\backslash{\protect\b@ckslash}
   \def\b@ckslash{\ifmmode \delimiter"26E30F \else \char`\\ \fi}
   \chardef\vbar=`\|
   }
   
   % reset resets definitions after you are done with the Adobe fonts
   \def\reset{%
   \def\`##1{{\accent18 ##1}}
   \def\'##1{{\accent19 ##1}}
   \def\v##1{{\accent20 ##1}} \let\^^_=\v
   \def\u##1{{\accent21 ##1}} \let\^^S=\u
   \def\=##1{{\accent22 ##1}}
   \def\^##1{{\accent94 ##1}} \let\^^D=\^
   \def\.##1{{\accent95 ##1}}
   \def\H##1{{\accent"7D ##1}}
   \def\~##1{{\accent"7E ##1}}
   \def\"##1{{\accent"7F ##1}}
   
   
   \chardef\%=`\%
   \chardef\&=`\&
   \chardef\#=`\#
   \chardef\$=`\$
   \chardef\ss="19
   \chardef\ae="1A
   \chardef\oe="1B
   \chardef\o="1C
   \chardef\AE="1D
   \chardef\OE="1E
   \chardef\O="1F
   \chardef\i="10 \chardef\j="11 % dotless letters
   \def\aa{\accent23a}
   \def\l{\char32l}
   \def\L{\leavevmode\setbox0\hbox{L}\hbox to\wd0{\hss\char32L}}
   }

Step 6

TEX and DVIPS. You are now ready to TEX/DVIPS. It is most convenient to do this in a shell file. A simple script like this is useful:

filename=$1
#  ..... argument is the filename to be TEXed without TEX extension
outputfile=robinhood
#  ..... base of all output files
tex $filename.tex
#  ..... TEX away!
dvips -h /home/pfa/Salsa.pfa\
      -h /home/pfa/Salsa-Swash.pfa\
      -o $outputfile.ps $filename
#  ..... dvips grabs the font files whose paths are 
#  ......given in full following the "-h" header command
ps2pdf $outputfile.ps $outputfile.pdf
#  ..... if you need a PDF file on the fly and have 
#  ..... ghostscript installed

Contact

Luc Devroye
School of Computer Science
McGill University
Montreal, Canada H3A 2K6
luc@cs.mcgill.ca
http://luc.devroye.org/index.html