Creating quality Adobe PDF files from TeX with DVIPS

by Kendall Whitehouse/EMERGE

Documents converted from the TeX typesetting language into the Adobe PostScript language or Acrobat Portable Document format (PDF) files usually contain fixed-resolution bitmap fonts that do not print or display well on a variety of printer and computer screens.

This document explains how to configure Tomas Rokicki's DVIPS program to use device-independent, scalable fonts in a PostScript language file or PDF document to achieve optimal font quality on any output device.

Background

The PostScript language can represent fonts in a number of different formats. PostScript Type 3 fonts can be described as either resolution-specific bitmaps or scalable outlines. PostScript Type 1 fonts are resolution-independent outline fonts that can be quickly rasterized by the font machinery in Adobe PostScript interpreters and software that uses the Adobe Type Manager (ATM) font rasterizer. Type 1 fonts can contain "hints" that tell the font machinery how to most effectively rasterize the font even at low resolutions or small font sizes.

The Computer Modern fonts, commonly used with Donald Knuth's TeX typesetting language, are typically rendered as fixed-resolution bitmaps (in TeX's PK format) even though they were derived from device-independent descriptions in Knuth's METAFONT language. A driver program translates TeX's DVI file and PK fonts to a printer-specific font format for printing.

The default behavior of DVIPS 1 is to convert the PK fonts into Type 3 bitmapped fonts when creating a PostScript language file. The resulting PostScript language file thus contains resolution-specific Type 3 bitmapped fonts that are not device- and resolution-independent like scalable Type 1 fonts.

If the PostScript language file is sent to a specific printer, device dependence may not be a problem. If the file is sent to printers of varying resolutions, however, this may be a problem because the fonts will not print at the native resolution of the printer. Sending a file with 300 dot-per-inch (dpi) fonts to a 600 dpi printer produces output no better than that of a 300 dpi printer.

Similar problems occur when the PostScript language file is converted to Adobe Portable Document Format (PDF). Since a PDF file is designed to be viewed and printed on a wide range of devices including both computer monitors and printers of varying resolutions, it works most effectively with scalable outline fonts.

Although Adobe Acrobat Distiller will convert a PostScript language file with bitmapped fonts into PDF, these fonts display slowly and do not render well on screen in the resulting PDF file. But, if you use Type 1 versions of the fonts you will get a compact file format that delivers the optimal font quality when used with any display screen, zoom mode, or printer resolution.

Using Type 1 Fonts With DVIPS

The default behavior of Rokicki's DVIPS is to embed Type 3 bitmapped fonts.

You can configure DVIPS to not embed bitmapped fonts by performing two steps:

  1. Create a font map file to identify the fonts you do not want to embed.
  2. Tell DVIPS how to reference the font map file.

You can tell DVIPS to use Type 1 fonts automatically for all of your DVIPS jobs or manually on a per-job basis depending on how you reference the font map file. Your system administrator can also configure DVIPS to automatically use Type 1 fonts globally for all users.

In each case you have the option to replace the Type 3 bitmapped fonts with references to the Type 1 fonts or to actually embed the code for the Type 1 fonts. The former creates smaller files, but requires the fonts to be available when the PostScript language file is printed or distilled. If the fonts are embedded in the PostScript language file, you don't need to worry about whether the fonts are present in the printer or available to Acrobat Distiller, but you'll have a larger PostScript language file and you may encounter memory limitations in certain Post-Script implementations.

You need access to the Type 1 versions of the fonts you use in your documents in order to embed the font information. Type 1 versions of the Computer Modern fonts are available in the BaKoMa collection (see "References and Resources") and from commercial type vendors.

Before distributing files with embedded fonts, consult the license agreement for your font package. Some typeface vendors do not allow you to embed complete fonts into a PDF or Post-Script language file for public distribution. Contact the type vendor for more information. You may embed all fonts included in the Adobe Type library.

Creating the Font Map File

To tell DVIPS to use Type 1 fonts rather than Type 3 fonts, you first need to create a font substitution, or font map file, that lists the names of the fonts that DVIPS should not embed as bitmaps.

For example, to instruct DVIPS to not embed the standard Computer Modern fonts, the font map file would look as follows:

cmb10
cmbsy10
cmbsy6
cmbsy7
cmbsy8
cmbsy9
cmbx10
cmbx12
.
.
.

This example assumes that the PostScript language names of the fonts (as referenced by the PostScript language interpreter's findfont operator) are identical to the names of the TFM files used by TeX (as is the case with the BaKoMa fonts).

If the PostScript language name for the font differs from the name used by TeX, use the font map file to create aliases to map the TeX name to the PostScript language name of the font. For example, if the Type 1 version of the CM fonts use upper case names, the font map would look like this:

cmb10    CMB10
cmbsy10  CMBSY10
cmbsy6   CMBSY6
cmbsy7   CMBSY7
cmbsy8   CMBSY8
cmbsy9   CMBSY9
cmbx10   CMBX10
cmbx12   CMBX12
.	  .
. 	  .
. 	  .

If you use other PostScript language fonts you can also use this alias feature to map the names of the PostScript language fonts to the names of the TeX font files, such as:

hlvr Helvetica
hlvo Helvetica-Oblique
hlvb Helvetica-Bold
hlvbo Helvetica-BoldOblique
. 	. 
. 	.
. 	.

Here the font file known to TeX as hlvr (the name of the TFM file) refers to the PostScript language font Helvetica, hlvo refers to Helvetica-Oblique, and so on.

In the previous three examples, only the names of the fonts are embedded in the PostScript language file, so the fonts must be available to the PostScript language interpreter when the file is printed or distilled.

To embed the code for the Type 1 font in the PostScript language file, add "<" followed by the path to the font file in either PFB or PFA format.

For example, if you have PFB versions of the CM fonts in the directory /usr/local/lib/tex/fonts/type1/, your font map file would look like:

cmb10 </usr/local/lib/tex/fonts/type1/cmb10.pfb
cmbsy10 </usr/local/lib/tex/fonts/type1/cmbsy10.pfb
cmbsy6 </usr/local/lib/tex/fonts/type1/cmbsy6.pfb
cmbsy7 </usr/local/lib/tex/fonts/type1/cmbsy7.pfb
cmbsy8 </usr/local/lib/tex/fonts/type1/cmbsy8.pfb
cmbsy9 </usr/local/lib/tex/fonts/type1/cmbsy9.pfb  
cmbx10 </usr/local/lib/tex/fonts/type1/cmbx10.pfb  
cmbx12 </usr/local/lib/tex/fonts/type1/cmbx12.pfb
. 		.
. 		.
. 		.

How the font substitutions specified in your font map file affect your DVIPS jobs depends on how you reference the font map file, as described in the next section.

Referencing the Font Map File

You can configure DVIPS to make these font substitutions automatically for all of your DVIPS jobs or manually on a per-job basis. Your system administrator can also configure DVIPS to automatically use Type 1 fonts globally for all users by placing the font map entries described above in the DVIPS system-wide psfonts.map file.

Using a Font Map File Automatically for All Jobs

To configure DVIPS to automatically perform the font substitutions for all jobs, create a font map file and then create a file in your home directory named .dvipsrc containing the line:

p +fontmap.map
where fontmap.map is the name of your font map file. (Make sure the p parameter is lowercase.)

With some implementations of DVIPS you may need to specify the full path to the font map file. For example, if your home directory is /users/kmw/ and your font map file is called embedCM.map, you would add the following line to your .dvipsrc file:

p +/users/kmw/embedCM.map

The plus sign (+) before the name of the font map file indicates that the font map file is referenced after the system-wide psfonts.map file and any assignments in your font map file are in addition to (and will override) those found in the psfonts.map file.

Now you can run DVIPS as usual:

dvips dvifilename

The font substitutions in your font map file will be used for all your DVIPS jobs.

Using a Font Map File On a Per-Job Basis

If you want to frequently switch between font map files, rather than editing your .dvipsrc file each time, you can create one or more printer-specificor, in this case, "output-specific" configuration files named config.printername that tell DVIPS to reference different font map files. You can then reference a specific configuration file by using the uppercase P parameter with the DVIPS command:

dvips -P printername dvifilename

For example, you can have a file CM.map like the first three examples that only places references to the fonts in the PostScript language file and another file embedCM.map that includes the font code as in the last example shown.

Then create a file named config.distiller containing a line with the lowercase p parameter that specifies the file CM.map:

p +CM.map
and a file named config.distillembed with the line that specifies the file embedCM.map:
p +embedCM.map

In some implementations of DVIPS you may need to give the complete path to the font map file.

The following command line would then create a PostScript language file containing only the names of the fonts:

dvips -P distiller dvifilename
The following command line would similarly create a PostScript language file with the actual font code embedded in the PostScript language file:
dvips -P distillembed dvifilename

Depending on how your implementation of DVIPS is configured, DVIPS may look for the config.printername file only in the current directory or in both the current directory and your home directory. If you want to change how DVIPS looks for configuration files, you can set the TEXCONFIG environment variable as described in the "Environment Variables" section of the DVIPS documentation.

Converting a PostScript Language File to PDF Using Acrobat Distiller

Once you've created a PostScript language file, use Acrobat Distiller to convert the PostScript language file to a PDF file. For more detailed information, refer to the Acrobat Distiller Online Guide.

If you embedded the Type 1 font code in the PostScript language file created by DVIPS, you can simply distill the PostScript language file as usual. If you embedded only references to the Type 1 fonts, you need to make sure Acrobat Distiller has access to the PostScript language fonts. See "Giving Acrobat Distiller access to fonts" in the Acrobat Distiller Online Guide.

Forcing Font Subsetting

Acrobat Distiller 2.1 provides configuration settings to enable both font embedding and font subsetting in a PDF file. For more information on these options see Embedding fonts in the Acrobat Distiller Online Guide.

Acrobat Distiller's default maximum subsetting threshold is 10%. In other words, if more than 10% of the characters in a font are included in the document, the entire font is embedded in the document.

You may want to change this setting to a higher value. This can produce a smaller PDF file and you may be required by the font vendor's license to subset the font if you plan to distribute the PDF file (contact the font vendor for details).

You can change the threshold for font embedding by adding a line to the Example.ps file in Acrobat Distiller's startup directory. In UNIX, the file is called DStartup.ps and is located in < installdir>/custom.

For example, to change the embedding threshold to the maximum value of 99 percent, open Example.ps with a text editor and add the following line to the file:

<< /SubsetFonts true /MaxSubsetPct 99 >> setdistillerparams
Although it doesn't matter where in the file you put this line, it's a good idea to place it in the "Font Embedding" section.

Save this file, restart Acrobat Distiller, and create the PDF file as usual. In most cases, all of the embedded fonts will now be subsetted.

If you later want to restore the original default setting, simply comment out this line by preced-ing it with a percent sign (%) and restart Acrobat Distiller.

Checking the PDF File

If you've been using Type 3 bitmapped fonts in your PDF files, you'll see the difference the Type 1 fonts make as soon as you open the file in Acrobat Reader or Exchange. With scalable Type 1 fonts the file displays more quickly and can be viewed in any zoom mode with no loss of font quality. Furthermore, you can print the PDF file on any printer and the fonts will be rendered at the maximum resolution of the printer.

If your document uses fonts that are not referenced in your font map file (but are available on your system in the standard TeX PK format) it may still include Type 3 fonts. The BaKoMa col-lection, for example, does not have the manfnt font typically used to typeset the METAFONT logo, and documents using this font will continue to include this as a bitmapped font.

Although the differences between the Type 3 bitmap fonts and the Type 1 fonts are usually apparent upon inspection, you can check which fonts are used in a PDF file by selecting File > Document Info > Fonts in Acrobat Reader or Exchange. From the Font Info window click List All Fonts.

The Type column will display whether the fonts are Type 1 or Type 3. If you're using DVIPS the Type 3 bitmapped fonts will also be named T1, T2, etc., while Type 1 fonts will display their correct names, such as cmr10, cmbx10, and so on. Fonts that have a six-character prefix added to the font name (such as KICOLA+cmr7) are Type 1 fonts that have been subsetted.

References and Resources

Files

Terms and Concepts

Notes

  1. The information on DVIPS is based primarily on DVIPS version 5.55 for Unix. Other versions may differ -- check the documentation provided with your version of DVIPS for more information.