Configuring TeX for PostScript Output

Configuring TeX for PostScript Output

There are a number of circumstances where it may be useful to create PostScript files from TeX for viewing and printing. A document may contain PostScript figures or use PostScript ``\specials'' such as those produced using the PStricks macros. In order to use PostScript effectively, three elements are required: This short note is intended to help users configure these three elements for optimal performance.

DVI to PostScript

A number of programs to convert TeX .dvi files to PostScript are available. One widely used example is Tom Rokicki's dvips, which is free, reliable, and supports a wide range of host systems. Commercial products are often integ rated with a dvi file viewer and may offer enhancements such as partial font downloading. The following discussion is based on dvips. The same approach can, however, be applied to configuring other programs.

Fonts

Early TeX implementations were based on the .pk bitmapped fonts generated by rendering metafont sources directly. In recent years, processor speeds have increased to the point where excellent performance for viewing documents can be obtained while rendering fonts as required. PostScript supports two main types of fonts: Dvips can use the .pk bitmap fonts generated using metafont, but since PostScript viewers do not make direct use of .pk fonts, either each PostScript file must include the fonts or the TeX bitmapped fonts must be con verted to Type 3 fonts. By using fonts that can be loaded as required by the viewer (i.e., Adobe Type 1 outline fonts) the size of the PostScript files can be greatly reduced. Adobe Type 1 versions of the Computer Modern fonts are available comme rcially or in the free Bakoma collection. In most cases these fonts produce printed output that is not visibly different from output produced using bitmapped .pk fonts. Some commercial .dvi to PostScript programs do not support the use of .pk fonts directly. In order to use a .pk font with such programs it is necessary to produce an Adobe Type 3 font using a separate utility.

PostScript viewers

Display PostScript from Adobe is available for unix workstations. One of the most common viewers is Aladdin Ghostscript in combination with a Ghostview front-end. A number of commercial products which emply the ghostscript engine are available.

A number of .dvi file viewers support a mechanism to include a rendering of a PostScript figure in a display produced directly from a .dvi file. This rendering may be embedded in the figure, stored in a separate file, or generat ed at run-time using a PostScript interpreter.

For typical TeX article, the size of the document is a small fraction (10--100k) of the combined size (1--2M) of the associated Type 1 font files. For such documents, it is important to minimize unnecessary copying of the fonts, both to reduce processing time and to conserve disk space (which may, for example, all ow a document to be saved on a single floppy disk).

Viewing TeX output using dvips, the Bakoma fonts, and Aladdin Ghostscript

This combination is freely available for a wide range of systems. Both programs use font map files to indicate the locations of the files containing the fonts used in a document. In the case of dvips, the font map may associate the name of a font with a disk file, in which case the file will be embedded in a PostScript file that uses the font. Fonts that are provided by the PostScript interpreter are called ``printer-resident''. In the case of ghostscript, the font map file must indicate a location for every font that will be displayed.

In order to obtain good performance when using Ghostview/ghostscript to view or print TeX documents, it is helpful to configure Ghostscript to load type 1 versions of the TeX fonts directly. The Bakoma fonts which can be downloaded from any CTAN archive mirror include a suitable FontMap fragment. This allows the PostScript file to be created without fonts, grealty reducing the size of the resulting PostScript file.

Configuration is not difficult, but requires coordination of the configuration files for dvips and ghostscript. dvips will require a configuration for ghostview and a configuration for printing (perhaps using ghostscript as a pr int filter to permit printing postscript documents on non-postscript printers). One configuration should be chosen as the default and the necessary changes made to the config.ps file. The other configuration is selected using the -P option on the dvips commmand line. For example, to invoke the ghostview configuration by specifying ``-P gv'', the file ``gv.cfg'' would contain:

* Ghostview configuration for .dvips
*
* specify font map for ghostview
p gv.map
* output to file
o
* resolution (affects rules and .pk fonts)
D 144
If ghostscript is used for printing, the same map files can be used for both viewing and printing; the only differences between the dvips configuration files would be the output line and the resolution.

In summary, the following files must be provided for each configuration:

  1. dvips configuration (printer.cfg);
  2. dvips font map; and
  3. ghostscript font map, (FontMap).
These files are described in the user documentation provided with dvips and ghostscript. Map file templates suitable for editing to use with dvips (cmfonts.map) and ghostscript (FontMap fragment) are included with the Bakoma fonts in the ``etc'' subdirectory.

Related applications

The ghostscript distribution includes a number of utilities that can be useful to the TeX community. In particular, the file ``ps2ai.ps'' by Jason Olszewski (olszewsk@splash.princeton.edu) can be used to convert most PostScript files to editable Adobe Illustrator format. An ``aimaker'' shell script to automate the use of ps2ai.ps and updated versions are available (anonymous ftp). Adobe Illustrator files can be edited using many commercial drawing packages, but the TeX fonts often cause problems. For example, TeX encodes the math minus sign in the ASCII NUL position. Many drawing programs use ASCII NUL to mark the end of a character string. A .dvi file created using TeX typically consists of many short strings. If the default encoding is used with ``ps2ai.ps'', programs which treat NUL as the string delimiter will drop the minus signs as well as any characters after the minus in th e string. To avoid such problems, modified versions of ``aimaker'' and ``ps2ai.ps'' which replace fonts by outline paths are available. In general, this method is suitable for creating slides and annotations for color images, but does not achieve the print quality obtainable using normal text fonts.