How to use Ghostscript

Table of contents

For other information, see the Ghostscript overview and, if necessary, how to install Ghostscript.


Invoking Ghostscript

This document describes how to use the command line Ghostscript client. Ghostscript is also used as a general engine inside other applications (for viewing files for example). Please refer to the documentation for those applications for using Ghostscript in other contexts.

The command line to invoke Ghostscript is essentially the same on all systems, although the name of the executable program itself may differ among systems. For instance, to invoke Ghostscript on unix-like systems type:

gs [options] {filename 1} ... [options] {filename N} ...

Here are some basic examples. The details of how these work are described below.

To view a file:

gs -dSAFER -dBATCH document.pdf
You'll be prompted to press return between pages.

To convert a figure to an image file:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 \
    -sOutputFile=tiger.png tiger.eps

To render the same image at 300 dpi:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 \
                -sOutputFile=tiger_300.png tiger.eps

To render a figure in grayscale:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=figure.png figure.pdf

To rasterize a whole document:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pgmraw -r150 \
                -dTextAlphaBits=4 -sOutputFile='paper-%00d.pgm' paper.ps

There are also a number of utility scripts for common to convert a PostScript document to PDF:

ps2pdf file.ps
The output is saved as file.pdf.

There are other utility scripts besides ps2pdf, including pdf2ps, ps2epsi, pdf2dsc, ps2ascii, ps2ps and ps2ps2. These just call Ghostscript with the appropriate (if complicated) set of options. You can use the 'ps2' set with eps files.

Ghostscript is capable of interpreting PostScript, encapsulated PostScript (EPS), DOS EPS (EPSF), and Adobe Portable Document Format (PDF). The interpreter reads and executes the files in sequence, using the method described under "File searching" to find them.

The interpreter runs in interactive mode by default. After processing the files given on the command line (if any) it reads further lines of PostScript language commands from the primary input stream, normally the keyboard, interpreting each line separately. To quit the interpreter, type "quit". The -dBATCH -dNOPAUSE options in the examples above disable the interactive prompting. The interpreter also quits gracefully if it encounters end-of-file or control-C.

The interpreter recognizes many options. An option may appear anywhere in the command line, and applies to all files named after it on the line. Many of them include "=" followed by a parameter. The most important are described in detail here. Please see the reference sections on options and devices for a more complete listing.

Help at the command line: gs -h

You can get a brief help message by invoking Ghostscript with the -h or -? switch, like this:

gs -h
gs -?

The message shows for that version of the Ghostscript executable:

On other systems the executable may have a different name:

System    invocation name
Unix  gs
VMS  gs
MS Windows 95 and later  gswin32c
MS Windows 3.1/Win32s  gswin32
OS/2  gsos2

Selecting an output device

Ghostscript has a notion of 'output devices' which handle saving or displaying the results in a particular format. Ghostscript comes with a diverse variety of such devices supporting vector and raster file output, screen display, driving various printers and communicating with other applications.

The command line option '-sDEVICE=device' selects which output device Ghostscript should use. If this option isn't given the default device (usually a display device) is used. Ghostscript's built-in help message (gs -h) lists the available output devices. For complete description of the devices distributed with Ghostscript and their options, please see the devices section of the documentation.

Note that this switch must precede the name of the first input file, and only its first use has any effect. For example, for printer output in a configuration that includes an Epson printer driver, instead of just 'gs myfile.ps' you might use

gs -sDEVICE=epson myfile.ps

The output device can also be set through the GS_DEVICE environment variable.

Once you invoke Ghostscript you can also find out what devices are available by typing 'devicenames ==' at the interactive prompt. You can set the output device and process a file from the interactive prompt as well:

(epson) selectdevice
(myfile.ps) run
All output then goes to the Epson printer instead of the display until you do something to change devices. You can switch devices at any time by using the selectdevice procedure, for instance like one of these:
(x11alpha) selectdevice
(epson) selectdevice

Output resolution

Some printers can print at several different resolutions, letting you balance resolution against printing speed. To select the resolution on such a printer, use the -r switch:

gs -sDEVICE=printer -rXRESxYRES
where XRES and YRES are the requested number of dots (or pixels) per inch. Where the two resolutions are same, as is the common case, you can simply use -rres.

The -r option is also useful for controlling the density of pixels when rasterizing to an image file. It is used this way in the examples at the beginning of this document.

Output to files

Ghostscript also allows you to control where it sends its output. With a display device this isn't necessary as the device handles presenting the output on screen internally. Some specialized printer drivers operate this way as well, but most devices are general and need to be directed to a particular file or printer.

To send the output to a file, use the -sOutputFile= switch. For instance, to direct all output into the file ABC.xyz, use

gs -sOutputFile=ABC.xyz

When printing on MS Windows systems, output normally goes directly to the printer, PRN. On Unix and VMS systems it normally goes to a temporary file which is sent to the printer in a separate step. When using Ghostscript as a file rasterizer (converting PostScript or PDF to a raster image format) you will of course want to specify an appropriately named file for the output.

Ghostscript also accepts the special filename '-' which indicates the output should be written to standard output (the command shell).

Be aware that filenames beginning with the character % have a special meaning in PostScript. If you need to specify a file name that actually begins with %, you must prepend the %os% filedevice explicitly. For example to output to a file named %abc, you need to specify

gs -sOutputFile=%os%%abc
Please see Ghostscript and the PostScript Language and the PostScript Language Reference Manual for more details on % and filedevices.

Note that on MS Windows systems, the % character also has a special meaning for the command processor (shell), so you will have to double it:

gs -sOutputFile=%%os%%%%abc (on MS Windows)

One page per file

Specifying a single output file works fine for printing and rasterizing figures, but sometimes you want images of each page of a multi-page document. You can tell Ghostscript to put each page of output in a series of similarly named files. To do this place a template '%d' in the filename which Ghostscript will replace with the page number.

You can also control the number of digits used in the file name:

-sOutputFile=ABC-%d.png
produces 'ABC-1.png', ... , 'ABC-10.png', ...

-sOutputFile=ABC-%03d.pgm
produces 'ABC-001.pgm', ... , 'ABC-010.pgm', ...

-sOutputFile=ABC_p%04d.tiff
produces 'ABC_p0001.tiff', ... , 'ABC_p0510.tiff', ... , 'ABC_p5238.tiff'

Generally %03d is the best option for normal documents.

Note however that this features is not supported by all devices; in particular it does not work with document-oriented output devices like pdfwrite and pswrite. See the -dFirstPage and -dLastPage switches below for a way to extract single pdf pages.

As noted above, on MS Windows systems, you will have to double the % character, e.g.,

gs -sOutputFile=ABC%%03d.xyz

Choosing paper size

Ghostscript is distributed configured to use U.S. letter paper as its default page size. There are two ways to select other paper sizes from the command line:

Individual documents can (and often do) specify a paper size, which takes precedence over the default size. To force a specific paper size and ignore the paper size specified in the document, select a paper size as just described, and also include the -dFIXEDMEDIA switch on the command line.

The default set of paper sizes will be included in the currentpagedevice in the InputAttributes dictionary with each paper size as one of the entries. The last entry in the dictionary (which has numeric keys) is a non-standard (Ghostscript extension) type of PageSize where the array has four elements rather than the standard two elements. This four element array represents a page size range where the first two elements are the lower bound of the range and the second two are the upper bound. By default these are [0, 0] for the lower bound and [16#fffff, 16#fffff] for the upper bound.
The range type of PageSize is intended to allow flexible page size sepcification for non-printer file formats such as JPEG, PNG, TIFF, EPS, ...
For actual printers, either the entire InputAttributes dictionary should be replaced or the range type entry should not be included. To simplify using the default page sizes in the InputAttributes dictionary, the command line option -dNORANGEPAGESIZE can be used. Using this option will result in automatic rotation of the document page if the requested page size matches one of the default page sizes.

Changing the installed default paper size

You can change the installed default paper size on an installed version of Ghostscript, by editing the initialization file gs_init.ps. This file is usually in the lib directory somewhere in the search path. See the section on finding files for details.

Find the line

% /DEFAULTPAPERSIZE (a4) def

Then to make A4 the default paper size, uncomment the line to change this to

/DEFAULTPAPERSIZE (a4) def

For a4 you can substitute any paper size Ghostscript knows.

This supecedes the previous method of uncommenting the line % (a4) ....

Sometimes the initialization files are compiled into Ghostscript and cannot be changed.

Interacting with pipes

As noted above, input files are normally specified on the command line. However, one can also "pipe" input into Ghostscript from another program by using the special file name '-' which is interpreted as standard input. Examples:

{some program producing ps} | gs [options] -
zcat paper.ps.gz | gs -

Ghostscript cannot read PDF files from standard input or a pipe because the PDF language inherently requires random access to the file. Thus '-' only works with PostScript documents.

When Ghostscript finishes reading from the pipe, it quits rather than going into interactive mode. Because of this, options and files after the '-' in the command line will be ignored.

On Unix and MS Windows systems you can send output to a pipe in the same way. For example, to pipe the output to lpr, use the command

gs -q -sOutputFile=- | lpr

In this case you must also use the -q switch to prevent Ghostscript from writing messages to standard output which become mixed with the intended output stream.

Similar results can be obtained with the %stdout and %pipe% filedevices. The example above would become

gs -sOutputFile=%stdout -q | lpr
or
gs -sOutputFile=%pipe%lpr
(again, doubling the % character on MS Windows systems.)

In the last case, -q isn't necessary since Ghostscript handles the pipe itself and messages sent to stdout will be printed as normal.

Using Ghostscript with PDF files

Ghostscript is normally built to interpret both PostScript and PDF files, examining each file to determine automatically whether its contents are PDF or PostScript. All the normal switches and procedures for interpreting PostScript files also apply to PDF files, with a few exceptions. In addition, the pdf2ps utility uses Ghostscript to convert PDF to (Level 2) PostScript.

Switches for PDF files

Here are some command line options specific to PDF

-dFirstPage=pagenumber
Begins interpreting on the designated page of the document.
-dLastPage=pagenumber
Stops interpreting after the designated page of the document.
-dPDFFitPage
Rather than selecting a PageSize given by the PDF MediaBox or CropBox (see -dUseCropBox), the PDF file will be scaled to fit the current device page size (usually the default page size).

This is useful to avoid clipping information on a PDF document when sending to a printer that may have unprintable areas at the edge of the media larger than allowed for in the document.

This is also useful for creating fixed size images of PDF files that may have a variety of page sizes, for example thumbnail images.

-dPrinted
-dPrinted=false
Determines whether the file should be displayed or printed using the "screen" or "printer" options for annotations and images. With -dPrinted, the output will use the file's "print" options; with -dPrinted=false, the output will use the file's "screen" options. If neither of these is specified, the output will use the screen options for any output device that doesn't have an OutputFile parameter, and the printer options for devices that do have this parameter.
-dUseCropBox
Sets the page size to the CropBox rather than the MediaBox. Some files have a CropBox that is smaller than the MediaBox and may include white space, registration or cutting marks outside the CropBox. Using this option will set the page size appropriately for a viewer.
-sPDFPassword=password
Sets the user or owner password to be used in decoding encrypted PDF files.

Problems interpreting a PDF file

Occasionally you may try to read or print a 'PDF' file that Ghostscript doesn't recognize as PDF, even though the same file can be opened and interpreted by an Adobe Acrobat viewer. In many cases, this is because of incorrectly generated PDF. Acrobat tends to be very forgiving of invalid PDF files. Ghostscript tends to expect files to conform to the standard. For example, even though valid PDF files must begin with %PDF, Acrobat will scan the first 1000 bytes or so for this string, and ignore any preceding garbage.

In the past, Ghostscript's policy has been to simply fail with an error message when confronted with these files. This policy has, no doubt, encouraged PDF generators to be more careful. However, we now recognize that this behavior is not very friendly for people who just want to use Ghostscript to view or print PDF files. Our new policy is to try to render broken PDF's, and also to print a warning, so that Ghostscript is still useful as a sanity-check for invalid files.

PDF files from standard input

The PDF language, unlike the PostScript language, inherently requires random access to the file. If you provide PDF to standard input using the special filename '-', Ghostscript will copy it to a temporary file before interpreting the PDF.

Using Ghostscript with EPS files

Encapsulated PostScript (EPS) files are intended to be incorporated in other PostScript documents and may not display or print on their own. An EPS file must conform to the Document Structuring Conventions, must include a %%BoundingBox line to indicate the rectangle in which it will draw, must not use PostScript commands which will interfere with the document importing the EPS, and can have either zero pages or one page. Ghostscript has support for handling EPS files, but requires that the %%BoundingBox be in the header, not the trailer. To customize EPS handling, see EPS parameters.

For the official description of the EPS file format, please refer to the Adobe documentation in their tech note #5002. It is available from: http://partners.adobe.com/public/developer/ps/index_specs.html

Using Ghostscript with overprinting and spot colors

In general with PostScript and PDF interpreters, the handling of overprinting and spot colors depends upon the process color model of the output device. Devices that produce gray or RGB output have an additive process color model. Devices which produce CMYK output have a subtractive process color model. Devices may, or may not, have support for spot colors.

Note: The differences in appearance of files with overprinting and spot colors caused by the differences in the color model of the output device are part of the PostScript and PDF specifications. They are not due to a limitation in the implementation of Ghostscript or its output devices.

With devices which use a subtractive process color model, both PostScript and PDF allow the drawing of objects using colorants (inks) for one or more planes without affecting the data for the remaining colorants. Thus the inks for one object may overprint the inks for another object. In some cases this produces a transparency like effect. (The effects of overprinting should not be confused with the PDF 1.4 blending operations which are supported for all output devices.) Overprinting is not allowed for devices with an additive process color model. With files that use overprinting, the appearance of the resulting image can differ between devices which produce RGB output versus devices which produce CMYK output. Ghostscript automatically overprints (if needed) when the output device uses a subtractive process color model. For example, if the file is using overprinting, differences can be seen in the appearance of the output from the tiff24nc and tiff32nc devices which use an RGB and a CMYK process color models.

Most of the Ghostscript output devices do not have file formats which support spot colors. Instead spot colors are converted using the tint transform function contained within the color space definition.. However there are several devices which have support for spot colors. The PSD format (Adobe Photoshop) produced by the psdcmyk device contains both the raster data plus an equivalent CMYK color for each spot color. This allows Photoshop to simulate the appearance of the spot colors. The display device (MS Windows, OS/2, gtk+) can be used with different color models: Gray, RGB, CMYK only, or CMYK plus spot colors (separation). The display device, when using its CMYK plus spot color (separation) mode, also uses an equivalent CMYK color to simulate the appearance of the spot color. The tiffsep device creates output files for each separation (CMYK and any spot colors present). It also creates a composite CMYK file using an equivalent CMYK color to simulate the appearance of spot colors. The xcfcmyk device creates output files with spot colors placed in separate alpha channels. (The XCF file format does not currently directly support spot colors.)

Overprinting with spot colors is not allowed if the tint transform function is being used to convert spot colors. Thus if spot colors are used with overprinting, then the appearance of the result can differ between output devices. One result would be obtained with a CMYK only device and another would be obtained with a CMYK plus spot color device. In a worst case situation where a file has overprinting with both process (CMYK) and spot colors, it is possible to get three different appearances for the same input file using the tiff24nc (RGB), tiff32nc (CMYK), and tiffsep (CMYK plus spot colors) devices.

In Adobe Acrobat, viewing of the effects of overprinting is enabled by the 'Overprint Preview' item in the 'Advanced' menu. This feature is not available in the free Acrobat Reader. The free Acrobat Reader also uses the tint transform functions to convert spot colors to the appropriate alternate color space.

How Ghostscript finds files

When looking for initialization files (gs_*.ps, pdf_*.ps), font files, the Fontmap file, files named on the command line, and resource files, Ghostscript first tests whether the file name specifies an absolute path.


Testing a file name for an absolute path
System    Does the name ...

Unix   Begin with / ?
MS Windows   Have : as its second character, or begin with /, \, or //servername/share/ ?
VMS   Contain a node, device, or root specification?

If the test succeeds, Ghostscript tries to open the file using the name given. Otherwise it tries directories in this order:

  1. The current directory (unless disabled by the -P- switch);
  2. The directories specified by -I switches in the command line, if any;
  3. The directories specified by the GS_LIB environment variable, if any;
  4. The directories specified by the GS_LIB_DEFAULT macro (if any) in the makefile when this executable was built.

GS_LIB_DEFAULT, GS_LIB, and the -I parameter may specify either a single directory or a list of directories separated by a character appropriate for the operating system (":" on Unix systems, "," on VMS systems, and ";" on MS Windows systems). We think that trying the current directory first is a very bad idea -- it opens serious security loopholes and can lead to very confusing errors if one has more than one version of Ghostscript in one's environment -- but when we attempted to change it, users insisted that we change it back. You can disable looking in the current directory first by using the -P- switch.

Note that Ghostscript does not use this file searching algorithm for the run or file operators: for these operators, it simply opens the file with the name given. To run a file using the searching algorithm, use runlibfile instead of run.

Finding PostScript Level 2 resources

Adobe specifies that resources are installed in a single directory. Ghostscript instead maintains a list of resource directories, and uses an extended method for finding resource files.

The search for a resource file depends on whether the value of the system parameter GenericResourceDir specifies an absolute path. The user may set it as explained in Resource-related parameters.

If the user doesn't set the system parameter GenericResourceDir, Ghostscript creates a default value for it with attaching the string ../Resource to directory paths explained in How Ghostscript finds files, except the current directory. The first successful combination is used.

If the value of the system parameter GenericResourceDir is an absolute path (the default), Ghostscript assumes a single resource directory. It concatenates :

  1. The value of the system parameter GenericResourceDir;
  2. The name of the resource category (for instance, CMap);
  3. The name of the resource instance (for instance, Identity-H).

If the value of the system parameter GenericResourceDir is not an absolute path, Ghostscript assumes multiple resource directories. In this case it concatenates :

  1. A directory listed in the section How Ghostscript finds files, except the current directory;
  2. The value of the system parameter GenericResourceDir;
  3. The name of the resource category (for instance, CMap);
  4. The name of the resource instance (for instance, Identity-H)
Due to possible variety of the part 1, the first successful combination is used. For example, if the value of the system parameter GenericResourceDir is the string ../Resource/ (or its equivalent in the file path syntax of the underlying platform), Ghostscript searches for ../Resource/CMap/Identity-H from all directories listed in How Ghostscript finds files. So in this example, if the user on a Windows platform specifies the command line option -I.;../gs/lib;c:/gs8.50/lib, Ghostscript searches for ../gs/Resource/CMap/Identity-H and then for c:/gs8.50/Resource/CMap/Identity-H.

To get a proper platform dependent syntax Ghostscript inserts the value of the system parameter GenericResourcePathSep (initially "/" on Unix and Windows, ":" on MacOS, "." or "]" on OpenVMS). The string ../Resource is replaced with a platform dependent equivalent.

In the case of multiple resource directories, the default ResourceFileName procedure retrieves either a path to the first avaliable resource, or if the resource is not available it returns a path starting with GenericResourceDir. Consequently Postscript installers of Postscript resources will overwrite an existing resource or add a new one to the first resource directory.

To look up fonts, after exhausting the search method described in the next section, it concatenates together

  1. the value of the system parameter FontResourceDir (initially /Resource/Font/)
  2. the name of the resource font (for instance, Times-Roman)

Note that even although the system parameters are named "somethingDir", they are not just plain directory names: they have "/" on the end, so that they can be concatenated with the category name or font name.

Font lookup

Ghostscript has a slightly different way to find the file containing a font with a given name. This rule uses not only the search path defined by -I, GS_LIB, and GS_LIB_DEFAULT as described above, but also the directory that is the value of the FontResourceDir system parameter, and an additional list of directories that is the value of the GS_FONTPATH environment variable (or the value provided with the -sFONTPATH= switch, if present).

At startup time, Ghostscript reads in the Fontmap files in every directory on the search path (or in the list provided with the -sFONTMAP= switch, if present): these files are catalogs of fonts and the files that contain them. (See the documentation of fonts for details.) Then, when Ghostscript needs to find a font that isn't already loaded into memory, it goes through a series of steps.

CID fonts (e.g. Chinese, Japanese and Korean) are found using a different method.


Differences between search path and font path
Search path     Font path

-I switch   -sFONTPATH= switch
 
GS_LIB and GS_LIB_DEFAULT environment variables   GS_FONTPATH environment variable
 
Consulted first   Consulted only if search path and FontResourceDir don't provide the file.
 
Font-name-to-file-name mapping given in Fontmap files; aliases are possible, and there need not be any relation between the font name in the Fontmap and the FontName in the file.   Font-name-to-file-name mapping is implicit -- the FontName in the file is used. Aliases are not possible.
 
Only fonts and files named in Fontmap are used.   Every Type 1 font file in each directory is available; if TrueType fonts are supported (the ttfont.dev feature was included when the executable was built), they are also available.

If you are using one of the following types of computer, you may wish to set the environment variable GS_FONTPATH to the value indicated so that Ghostscript will automatically acquire all the installed Type 1 (and, if supported, TrueType) fonts (but see below for notes on systems marked with "*"):


Suggested GS_FONTPATH for different systems
     System type    GS_FONTPATH

    Digital Unix   /usr/lib/X11/fonts/Type1Adobe
    Ultrix   /usr/lib/DPS/outline/decwin
    HP-UX 9   /usr/lib/X11/fonts/type1.st/typefaces
    IBM AIX   /usr/lpp/DPS/fonts/outlines
/usr/lpp/X11/lib/X11/fonts/Type1
/usr/lpp/X11/lib/X11/fonts/Type1/DPS
    NeXT   /NextLibrary/Fonts/outline
*   SGI IRIX   /usr/lib/DPS/outline/base
/usr/lib/X11/fonts/Type1
    SunOS 4.x
(NeWSprint only)
  newsprint_2.5/SUNWsteNP/reloc/$BASEDIR/NeWSprint/
    small_openwin/lib/fonts
**   SunOS 4.x   /usr/openwin/lib/X11/fonts/Type1/outline
**   Solaris 2.x   /usr/openwin/lib/X11/fonts/Type1/outline
    VMS   SYS$COMMON:[SYSFONT.XDPS.OUTLINE]

* On SGI IRIX systems, you must use Fontmap.SGI in place of Fontmap or Fontmap.GS, because otherwise the entries in Fontmap will take precedence over the fonts in the FONTPATH directories.

** On Solaris systems simply setting GS_FONTPATH or using -sFONTPATH= may not work, because for some reason some versions of Ghostscript can't seem to find any of the Type1 fonts in /usr/openwin/lib/X11/fonts/Type1/outline. (It says: "15 files, 15 scanned, 0 new fonts". We think this problem has been fixed in Ghostscript version 6.0, but we aren't sure because we've never been able to reproduce it.) See Fontmap.Sol instead. Also, on Solaris 2.x it's probably not worth your while to add Sun's fonts to your font path and Fontmap. The fonts Sun distributes on Solaris 2.x in the directories

/usr/openwin/lib/X11/fonts/Type1
/usr/openwin/lib/X11/fonts/Type1/outline

are already represented among the ones distributed as part of Ghostscript; and on some test files, Sun's fonts have been shown to cause incorrect displays with Ghostscript.

These paths may not be exactly right for your installation; if the indicated directory doesn't contain files whose names are familiar font names like Courier and Helvetica, you may wish to ask your system administrator where to find these fonts.

Adobe Acrobat comes with a set of fourteen Type 1 fonts, on Unix typically in a directory called .../Acrobat3/Fonts. There is no particular reason to use these instead of the corresponding fonts in the Ghostscript distribution (which are of just as good quality), except to save about a megabyte of disk space, but the installation documentation explains how to do it on Unix.

CID fonts

CID fonts are PostScript resources containing a large number of glyphs (e.g. glyphs for Far East languages, Chinese, Japanese and Korean). Please refer to the PostScript Language Reference, third edition, for details.

CID font resources are a different kind of PostScript resource from fonts. In particular, they cannot be used as regular fonts. CID font resources must first be combined with a CMap resource, which defines specific codes for glyphs, before it can be used as a font. This allows the reuse of a collection of glyphs with different encodings.

The simplest method to request a font composed of a CID font resource and a CMap resource in a PostScript document is

/CIDFont-CMap findfont
where CIDFont is a name of any CID font resource, and CMap is a name of a CMap resource designed for the same character collection. The interpreter will compose the font automatically from the specified CID font and CMap resources. Another method is possible using the composefont operator.

CID fonts must be placed in the /Resource/CIDFont/ directory. They are not found using Font lookup on the search path or font path.

CID font substitution

Substitution of CID font resources is controlled by the Ghostscript configuration file lib/cidfmap, which defines a CID font resource map. The file forms a table of records, each of which should use one of two formats, explained below. Users may modify lib/cidfmap to configure Ghostscript for a specific need.

To substitute a CID font resource with another CID font resource, add a record like this :

/Substituted /Original ;
where Substituted is a name of CID font resource being used by a document, and Original is a name of an available CID font resource. Please pay attention that both them must be designed for same character collection. In other words, you cannot substitute a Japanese CID font resource with a Korean CID font resource, etc. CMap resource names must not appear in lib/cidfmap. The trailing semicolon and the space before it are both required.

To substitute (emulate) a CID font resource with a TrueType font file, add a record like this :

/Substituted << keys&values >> ;
Where keys&values are explained in the table below.
Key Type Description
/Path string A path to a TrueType font file. This must be an absolute path. If using -dSAFER, the directory containing the font file must be on one of the permitted paths.
/FileType name Must be /TrueType.
/SubfontID integer (optional) Index of the font in font collection, such as TTC. This is ignored if Path doesn't specify a collection. The first font in a collection is 0. Default value is 0.
/CSI array of 2 elements (required) Information for building CIDSystemInfo. The first element is a string, which specifies Ordering. The second element is a number, which specifies Supplement.

Currently only CIDFontType 2 can be emulated with a TrueType font. The TrueType font must contain enough characters to cover an Adobe character collection, which is specified in Ordering and used in documents.

Examples :

/Ryumin-Medium /ShinGo-Bold ;
/MS-Mincho << /FileType /TrueType /Path (C:/WINDOWS/fonts/msmincho.ttc) /SubfontID 0 /CSI [(Japan1) 3] >> ;
/Ryumin-Light /MS-Mincho ;

/Batang << /FileType /TrueType /Path (C:/WINDOWS/fonts/batang.ttc) /SubfontID 0 /CSI [(Korea1) 3] >> ;
/Gulim << /FileType /TrueType /Path (C:/WINDOWS/fonts/gulim.ttc) /SubfontID 0 /CSI [(Korea1) 3] >> ;
/Dotum << /FileType /TrueType /Path (C:/WINDOWS/fonts/gulim.ttc) /SubfontID 2 /CSI [(Korea1) 3] >> ;
/HYSMyeongJo-Medium /Batang ;
/HYRGoThic-Medium /Gulim ;
/HYGoThic-Medium /Dotum ;

/SimSun << /FileType /TrueType /Path (C:/WINDOWS/fonts/simsun.ttc) /SubfontID 0 /CSI [(GB1) 2] >> ;
/SimHei << /FileType /TrueType /Path (C:/WINDOWS/fonts/simhei.ttf) /SubfontID 0 /CSI [(GB1) 2] >> ;
/STSong-Light /SimSun ;
/STHeiti-Regular /SimHei ;

Note that the font file path uses Postscript syntax for strings. Due to that backslashes must be represented as a double backslash each.

Note that loading truetype fonts directly from >/Resources/CIDFont is no longer supported. There is no reliable way to generate a character ordering for truetype fonts. The 7.0x versions of Ghostscript supported this by assuming a Japanese character ordering. This is replaced in the 8.0x and later releases with the more general cidfmap mechanism.

The PDF specification requires CID font files to be embedded, however some documents omit them. As a workaround the PDF interpreter applies an additional substitution method when a requested CID font resource is not embedded and it is not available. It takes values of the keys Registry and Ordering from the CIDFontSystem dictionary, and concatenates them with a dash inserted. For example, if a PDF CID font resource specifies

/CIDSystemInfo << /Registry (Adobe) /Ordering (CNS1) /Supplement 1 >>
the generated subsitituite name is Adobe-CNS1. The latter may look some confusing for a font name, but we keep it for compatibility with older Ghostscript versions, which do so due to a historical reason. Add a proper record to lib/cidfmap to provide it.

Please note that when a PDF font resource specifies

/Registry (Adobe) /Ordering (Identity)
there is no way to determine the language properly. If the CID font file is not embedded, the Adobe-Identity record depends on the document and a correct record isn't possible when a document refers to multiple Far East languages. In the latter case add individual records for specific CID font names used in the document.

Consequently, if you want to handle any PDF document with non-embedded CID fonts (which isn't a correct PDF), you need to create a suitable lib/cidfmap by hand, possibly a specific one for each document.

Temporary files


Where Ghostscript puts temporary files
Platform     Filename     Location

MS Windows and OpenVMS   _temp_XX.XXX   Current directory
OS/2   gsXXXXXX   Current directory
Unix   gs_XXXXX   /tmp

You can change in which directory Ghostscript creates temporary files by setting the TMPDIR or TEMP environment variable to the name of the directory you want used. Ghostscript currently doesn't do a very good job of deleting temporary files if it exits because of an error; you may have to delete them manually from time to time.


Notes on specific platforms

Unix

The Ghostscript distribution includes some Unix shell scripts to use with Ghostscript in different environments. These are all user-contributed code, so if you have questions, please contact the user identified in the file, not Aladdin Enterprises or artofcode LLC.

pv.sh
Preview a specified page of a dvi file in an X window
sysvlp.sh
System V 3.2 lp interface for parallel printer
pj-gs.sh
Printing on an H-P PaintJet under HP-UX
unix-lpr.sh
Queue filter for lpr under Unix; its documentation is intended for system administrators
lprsetup.sh
Setup for unix-lpr.sh

VMS

Using X Windows on VMS

If you are using on an X Windows display, you can set it up with the node name and network transport, for instance

$ set display/create/node="doof.city.com"/transport=tcpip

and then run Ghostscript by typing gs at the command line.


MS Windows

The name of the Ghostscript command line executable on MS Windows is gswin32c so use this instead of the plain 'gs' in the quickstart examples.

You must add gs\bin and gs\lib to the PATH, where gs is the top-level Ghostscript directory.

When passing options to ghostcript through a batch file wrapper such as ps2pdf.bat you need to substitute '#' for '=' as the separator between options and their arguments. For example:

ps2pdf -sPAPERSIZE#a4 file.ps file.pdf
Ghostscript treats '#' the same internally, and the '=' is mangled by the command shell.

There is also an older version for windows called just gswin32 that provides its own window for the interactive postscript prompt. Except on Windows 3.1, gswin32c is the better option since it uses the native command prompt window.


MS-DOS

Note: Ghostscript is no longer supported on MS-DOS.

Invoking Ghostscript from the command prompt in Windows is supported by the Windows executable described above.


X Windows

Ghostscript looks for the following resources under the program name ghostscript and class name Ghostscript; the ones marked "**" are calculated from display metrics:


X Windows resources
Name    Class    Default

background   Background   white
foreground   Foreground   black
borderColor   BorderColor   black
borderWidth   BorderWidth   1
geometry   Geometry   NULL
xResolution   Resolution   **
yResolution   Resolution   **
useExternalFonts   UseExternalFonts   true
useScalableFonts   UseScalableFonts   true
logExternalFonts   LogExternalFonts   false
externalFontTolerance   ExternalFontTolerance   10.0
palette   Palette   Color
maxGrayRamp   MaxGrayRamp   128
maxRGBRamp   MaxRGBRamp   5
maxDynamicColors   MaxDynamicColors   256
useBackingPixmap   UseBackingPixmap   true
useXPutImage   UseXPutImage   true
useXSetTile   UseXSetTile   true
regularFonts   RegularFonts   See "X fonts"
symbolFonts   SymbolFonts   See "X fonts"
dingbatFonts   DingbatFonts   See "X fonts"

X resources

Working around bugs in X servers

The "use..." resources exist primarily to work around bugs in X servers.

X fonts

To use native X11 fonts, Ghostscript must map PostScript font names to the XLFD font names. The resources regularFonts (fonts available in standard or ISO-Latin-1 encoding), symbolFonts (using Symbol encoding), and dingbatFonts (using Dingbat encoding) give the name mapping for different encodings. The XLFD font name in the mapping must contain 7 dashes; the X driver adds the additional size and encoding fields to bring the total number of dashes in the font name to 14. See the appendix "X default font mappings" for the full list of default mappings.

Users who switch regularly between different X servers may wish to use the "*" wild card in place of the foundry name (itc, monotype, linotype, b&h, or adobe); users who do not switch X servers should leave the explicit foundry in the name, since it speeds up access to fonts.

Ghostscript takes advantage of the "HP XLFD Enhancements," if available, to use native X11 fonts for fonts that are anamorphically scaled, rotated, or mirrored. If the changes have been installed to the X or font server, they are automatically used when appropriate.

Using Ghostscript fonts on X displays

Font files distributed with Ghostscript can be used on X Windows displays. You can find full instructions in the documentation on fonts.

X device parameters

In addition to the device parameters recognized by all devices, Ghostscript's X driver provides parameters to adjust its performance. Users will rarely need to modify these. Note that these are parameters to be set with the -d switch in the command line (e.g., -dMaxBitmap=10000000), not resources to be defined in the ~/.Xdefaults file.

AlwaysUpdate <boolean>
If true, the driver updates the screen after each primitive drawing operation; if false (the default), the driver uses an intelligent buffered updating algorithm.
MaxBitmap <integer>
If the amount of memory required to hold the pixmap for the window is no more than the value of MaxBitmap, the driver will draw to a pixmap in Ghostscript's address space (called a "client-side pixmap") and will copy it to the screen from time to time; if the amount of memory required for the pixmap exceeds the value of MaxBitmap, the driver will draw to a server pixmap. Using a client-side pixmap usually provides better performance -- for bitmap images, possibly much better performance -- but since it may require quite a lot of RAM (e.g., about 2.2 Mb for a 24-bit 1024x768 window), the default value of MaxBitmap is 0.
MaxTempPixmap, MaxTempImage, MaxBufferedTotal, MaxBufferedArea, MaxBufferedCount <integer>
These control various aspects of the driver's buffering behavior. For details, please consult the source file gdevx.h.

SCO Unix

Because of bugs in the SCO Unix kernel, Ghostscript will not work if you select direct screen output and also allow it to write messages on the console. If you are using direct screen output, redirect Ghostscript's terminal output to a file.


Command line options

Unless otherwise noted, these switches can be used on all platforms.

General switches

Input control

@filename
Causes Ghostscript to read filename and treat its contents the same as the command line. (This was intended primarily for getting around DOS's 128-character limit on the length of a command line.) Switches or file names in the file may be separated by any amount of white space (space, tab, line break); there is no limit on the size of the file.
-- filename arg1 ...
-+ filename arg1 ...
Takes the next argument as a file name as usual, but takes all remaining arguments (even if they have the syntactic form of switches) and defines the name ARGUMENTS in userdict (not systemdict) as an array of those strings, before running the file. When Ghostscript finishes executing the file, it exits back to the shell.
-@ filename arg1 ...
Does the same thing as -- and -+, but expands @filename arguments.
-
-_
These are not really switches: they tell Ghostscript to read from standard input, which is coming from a file or a pipe, with or without buffering. On some systems, Ghostscript may read the input one character at a time, which is useful for programs such as ghostview that generate input for Ghostscript dynamically and watch for some response, but can slow processing. If performance is significantly slower than with a named file, try '-_' which always reads the input in blocks. However, '-' is equivalent on most systems.
-c tokens ...
Interprets arguments as PostScript code up to the next argument that begins with "-" followed by a non-digit, or with "@". For example, if the file quit.ps contains just the word "quit", then -c quit on the command line is equivalent to quit.ps there. Each argument must be exactly one token, as defined by the token operator.
-f
Interprets following non-switch arguments as file names to be executed using the normal run command. Since this is the default behavior, -f is useful only for terminating the list of tokens for the -c switch.
-ffilename
Execute the given file, even if its name begins with a "-" or "@".

File searching

Note that by "library files" here we mean all the files identified using the search rule under "How Ghostscript finds files" above: Ghostscript's own initialization files, fonts, and files named on the command line.

-Idirectories
Adds the designated list of directories at the head of the search path for library files.
-P
Makes Ghostscript look first in the current directory for library files. This is currently the default.
-P-
Makes Ghostscript not look first in the current directory for library files (unless, of course, the first explicitly supplied directory is ".").

Setting parameters

-Dname
-dname
Define a name in systemdict with value=true.
-Dname=token
-dname=token
Define a name in systemdict with the given definition. The token must be exactly one token (as defined by the token operator) and must not contain any whitespace. If the token is a non-literal name, it must be true, false, or null.
-Sname=string
-sname=string
Define a name in systemdict with a given string as value. This is different from -d. For example, -dXYZ=35 on the command line is equivalent to the program fragment
/XYZ 35 def

whereas -sXYZ=35 is equivalent to

/XYZ (35) def
-uname
Un-define a name, cancelling -d or -s.

Note that the initialization file gs_init.ps makes systemdict read-only, so the values of names defined with -D, -d, -S, and -s cannot be changed -- although, of course, they can be superseded by definitions in userdict or other dictionaries. However, device parameters set this way (PageSize, Margins, etc.) are not read-only, and can be changed by code in PostScript files.

-gnumber1xnumber2
Equivalent to -dDEVICEWIDTH=number1 and -dDEVICEHEIGHT=number2, specifying the device width and height in pixels for the benefit of devices such as X11 windows and VESA displays that require (or allow) you to specify width and height. Note that this causes documents of other sizes to be clipped, not scaled: see -dFIXEDMEDIA below.
-rnumber (same as -rnumberxnumber)
-rnumber1xnumber2
Equivalent to -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2, specifying the device horizontal and vertical resolution in pixels per inch for the benefit of devices such as printers that support multiple X and Y resolutions.

Suppress messages

-q
Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET.

Parameter switches (-d and -s)

As noted above, -d and -s define initial values for PostScript names. Some of these names are parameters that control the interpreter or the graphics engine. You can also use -d or -s to define a value for any device parameter of the initial device (the one defined with -sDEVICE=, or the default device if this switch is not used). For example, since the ppmraw device has a numeric GrayValues parameter that controls the number of bits per component, -sDEVICE=ppmraw -dGrayValues=16 will make this the default device and set the number of bits per component to 4 (log2(16)).

Rendering parameters

-dCOLORSCREEN
-dCOLORSCREEN=0
-dCOLORSCREEN=false
On high-resolution devices (at least 150 dpi resolution, or -dDITHERPPI specified), -dCOLORSCREEN forces the use of separate halftone screens with different angles for CMYK or RGB if halftones are needed (this produces the best-quality output); -dCOLORSCREEN=0 uses separate screens with the same frequency and angle; -dCOLORSCREEN=false forces the use of a single binary screen. The default if COLORSCREEN is not specified is to use separate screens with different angles if the device has fewer than 5 bits per color, and a single binary screen (which is never actually used under normal circumstances) on all other devices.
-dDITHERPPI=lpi
Forces all devices to be considered high-resolution, and forces use of a halftone screen or screens with lpi lines per inch, disregarding the actual device resolution. Reasonable values for lpi are N/5 to N/20, where N is the resolution in dots per inch.
-dDOINTERPOLATE
Turns on image interpolation for all images, improving image quality for scaled images at the expense of speed. Note that -dNOINTERPOLATE overrides -dDOINTERPOLATE if both are specified.
-dTextAlphaBits=n
-dGraphicsAlphaBits=n
These options control the use of subsample antialiasing. Their use is highly recommended for producing high quality rasterizations. The subsampling box size n should be 4 for optimum output, but smaller values can be used for faster rendering. Antialiasing is enabled separately for text and graphics content. Allowed values are 1, 2 or 4.

Note that because of the way antialiasing blends the edges of shapes into the background when they are drawn some files that rely on joining separate filled polygons together to cover an area may not render as expected with GraphicsAlphaBits at 2 or 4. If you encounter strange lines within solid areas, try rendering that file again with -dGraphicsAlphaBits=1.

-dAlignToPixels=n
Chooses glyph alignent to integral pixel boundaries (if set to the value 1) or to subpixels (value 0). Subpixels are a smaller raster grid which is used internally for text antialiasing. The number of subpixels in a pixel usually is 2^TextAlphaBits, but this may be automatically reduced for big characters to save space in character cache.

The parameter has no effect if -dTextAlphaBits=1. Default value is 0.

Setting -dAlignToPixels=0 can improve rendering of poorly hinted fonts, but may impair the appearance of well-hinted fonts.

-dGridFitTT=n
This specifies the initial value for the implementation specific user parameter GridFitTT. It controls grid fitting of True Type fonts (Sometimes referred to as "hinting", but strictly speaking the latter is a feature of Type 1 fonts). Setting this to 2 enables automatic grid fitting for True Type glyphs. The value 0 disables grid fitting. The default value is 2. For more information see the description of the user parameter GridFitTT.
-dUseCIEColor
Set UseCIEColor in the page device dictionary, remapping device-dependent color values through a CIE color space. This can can improve conversion of CMYK documents to RGB.
-dNOCIE
Substitutes DeviceGray and DeviceRGB for CIEBasedA and CIEBasedABC color spaces respectively. Useful only on very slow systems where color accuracy is less important.
-dNOSUBSTDEVICECOLORS
This switch prevents the substitution of the ColorSpace resources (DefaultGray, DefaultRGB, and DefaultCMYK) for the DeviceGray, DeviceRGB, and DeviceCMYK color spaces. This switch is primarily useful for PDF creation using the pdfwrite device when retaining the color spaces from the original document is important.
-dNOPSICC
Disables the automatic loading and use of an input color space that is contained in a PostScript file as DSC comments starting with the %%BeginICCProfile: comment. ICC profiles are sometimes embedded by applications to convey the exact input color space allowing better color fidelity. Since the embedded ICC profiles often use multidimensional RenderTables, color conversion may be slower than using the Default color conversion invoked when the -dUseCIEColor option is specified, therefore the -dNOPSICC option may result in improved performance at slightly reduced color fidelity.
-dNOINTERPOLATE
Turns off image interpolation, improving performance on interpolated images at the expense of image quality. -dNOINTERPOLATE overrides -dDOINTERPOLATE.
-dNOTRANSPARENCY
Turns off PDF 1.4 transparency, resulting in faster (but possibly incorrect) rendering of pages containing PDF 1.4 transparency and blending.
-dNO_TN5044
Turns off the TN 5044 psuedo operators. These psuedo operators are not a part of the official Postscript specification. However they are defined in Technical Note #5044 Color Separation Conventions for PostScript Language Programs. These psuedo operators are required for some files from QuarkXPress. However some files from Corel 9 and Illustrator 88 do not operate properly if these operators are present.
-dDOPS
Enables processing of DoPS directives in PDF files. DoPS has in fact been deprecated for some time. Use of this option is not recommended in security-conscious applications, as it increases the scope for malicious code. -dDOPS has no effect on processing of PostScript source files. Note: in releases 7.30 and earlier, processing of DoPS was always enabled.

Page parameters

-dFIXEDMEDIA
Causes the media size to be fixed after initialization, forcing pages of other sizes or orientations to be clipped. This may be useful when printing documents on a printer that can handle their requested paper size but whose default is some other size. Note that -g automatically sets -dFIXEDMEDIA, but -sPAPERSIZE= does not.
-dFIXEDRESOLUTION
Causes the media resolution to be fixed similarly. -r automatically sets -dFIXEDRESOLUTION.
-dORIENT1=true
-dORIENT1=false
Defines the meaning of the 0 and 1 orientation values for the setpage[params] compatibility operators. The default value of ORIENT1 is true (set in gs_init.ps), which is the correct value for most files that use setpage[params] at all, namely, files produced by badly designed applications that "know" that the output will be printed on certain roll-media printers: these applications use 0 to mean landscape and 1 to mean portrait. -dORIENT1=false declares that 0 means portrait and 1 means landscape, which is the convention used by a smaller number of files produced by properly written applications.
-dDEVICEWIDTHPOINTS=w
-dDEVICEHEIGHTPOINTS=h
Sets the initial page width to w or initial page height to h respectively, specified in 1/72" units.
-sDEFAULTPAPERSIZE=a4
This value will be used to replace the device default papersize ONLY if the default papersize for the device is 'letter' or 'a4' serving to insulate users of A4 or 8.5x11 from particular device defaults (the collection of contributed drivers in Ghostscript vary as to the default size).

Font-related parameters

-dDISKFONTS
Causes individual character outlines to be loaded from the disk the first time they are encountered. (Normally Ghostscript loads all the character outlines when it loads a font.) This may allow loading more fonts into memory at the expense of slower rendering. DISKFONTS is effective only if the diskfont feature was built into the executable; otherwise it is ignored.
-dLOCALFONTS
Causes Type 1 fonts to be loaded into the current VM -- normally local VM -- instead of always being loaded into global VM. Useful only for compatibility with Adobe printers for loading some obsolete fonts.
-dNOCCFONTS
Suppresses the use of fonts precompiled into the Ghostscript executable. See "Precompiling fonts" in the documentation on fonts for details. This is probably useful only for debugging.
-dNOFONTMAP
Suppresses the normal loading of the Fontmap file. This may be useful in environments without a file system.
-dNOFONTPATH
Suppresses consultation of GS_FONTPATH. This may be useful for debugging.
-dNOPLATFONTS
Disables the use of fonts supplied by the underlying platform (X Windows or Microsoft Windows). This may be needed if the platform fonts look undesirably different from the scalable fonts.
-sFONTMAP=filename1;filename2;...
Specifies alternate name or names for the Fontmap file. Note that the names are separated by ":" on Unix systems, by ";" on MS Windows systems, and by "," on VMS systems, just as for search paths.
-sFONTPATH=dir1;dir2;...
Specifies a list of directories that will be scanned when looking for fonts not found on the search path, overriding the environment variable GS_FONTPATH.
-sSUBSTFONT=fontname
Causes the given font to be substituted for all unknown fonts, instead of using the normal intelligent substitution algorithm. Also, in this case, the font returned by findfont is the actual font named fontname, not a copy of the font with its FontName changed to the requested one. THIS OPTION SHOULD NOT BE USED WITH HIGH LEVEL DEVICES, such as pdfwrite, because it prevents such devices from providing the original font names in the output document. The font specified (fontname) will be embedded instead, limiting all future users of the document to the same approximate rendering.

Resource-related parameters

-sGenericResourceDir=path
Specifies a path to resource files. The value is platform dependent. It must end with a directory separator.

Adobe specifies GenericResourceDir to be an absolute path to a single resource directory. Ghostscript instead maintains multiple resource directories and uses an extended method for finding resources, which is explained in "Finding PostScript Level 2 resources".

Due to the extended search method, Ghostscript uses GenericResourceDir only as a default directory for resources being not installed. Therefore GenericResourceDir may be considered as a place where new resources to be installed. The default implementation of the function ResourceFileName uses GenericResourceDir when (1) it is an absolute path, or (2) the resource file is absent. The extended search method does not call ResourceFileName .

Default value is (./Resource/) for Unix, and an equivalent one on other platforms.

-sFontResourceDir=path
Specifies a path where font files are installed. It's meaning is similar to GenericResourceDir.

Default value is (./Font/) for Unix, and an equivalent one on other platforms.

Interaction-related parameters

-dBATCH
Causes Ghostscript to exit after processing all files named on the command line, rather than going into an interactive loop reading PostScript commands. Equivalent to putting -c quit at the end of the command line.
-dNOPAGEPROMPT
Disables only the prompt, but not the pause, at the end of each page. This may be useful on PC displays that get confused if a program attempts to write text to the console while the display is in a graphics mode.
-dNOPAUSE
Disables the prompt and pause at the end of each page. Normally one should use this (along with -dBATCH) when producing output on a printer or to a file; it also may be desirable for applications where another program is "driving" Ghostscript.
-dNOPROMPT
Disables the prompt printed by Ghostscript when it expects interactive input, as well as the end-of-page prompt (-dNOPAGEPROMPT); also disables the implicit flushpage that normally occurs each time Ghostscript asks for more input. This allows piping input directly into Ghostscript, as long as the data doesn't refer to currentfile.
-dQUIET
Suppresses routine information comments on standard output. This is currently necessary when redirecting device output to standard output.
-dSHORTERRORS
Makes certain error and information messages more Adobe-compatible.
-sstdout=filename
Redirect PostScript %stdout to a file or stderr, to avoid it being mixed with device stdout. To redirect stdout to stderr use -sstdout=%stderr. To cancel redirection of stdout use -sstdout=%stdout or -sstdout=-.
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than standard input, at the end of each page. This may be useful if input is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE.

Device and output selection parameters

-dNODISPLAY
Initializes Ghostscript with a null device (a device that discards the output image) rather than the default device or the device selected with -sDEVICE=. This is usually useful only when running PostScript code whose purpose is to compute something rather than to produce an output image; for instance, when converting PostScript to PDF.
-sDEVICE=device
Selects an alternate initial output device.
-sOutputFile=filename
Selects an alternate output file (or pipe) for the initial output device, as described above.

EPS parameters

-dEPSCrop
Crop an EPS file to the bounding box. This is useful when converting an EPS file to a bitmap.
-dEPSFitPage
Resize an EPS file to fit the page. This is useful for enlarging an EPS file to fit the paper size when printing.
-dNOEPS
Prevent special processing of EPS files. This is useful when EPS files have incorrect Document Structuring Convention comments.

Other parameters

-dDELAYBIND
Causes bind to remember all its invocations, but not actually execute them until the .bindnow procedure is called. Useful only for certain specialized packages like pstotext that redefine operators. See the documentation for .bindnow for more information on using this feature.
-dDOPDFMARKS
Causes pdfmark to be called for bookmarks, annotations, links and cropbox when processing PDF files. Normally, pdfmark is only called for these types for PostScript files or when the output device requests it (e.g. pdfwrite device).
-dJOBSERVER
Define \004 (^D) to start a new encapsulated job used for compatibility with Adobe PS Interpreters that ordinarily run under a job server. The -dNOOUTERSAVE switch is ignored if -dJOBSERVER is specified since job servers always execute the input PostScript under a save level, although the exitserver operator can be used to escape from the encapsulated job and execute as if the -dNOOUTERSAVE was specified.

This also requires that the input be from stdin, otherwise an error will result (Error: /invalidrestore in --restore--).

Example usage is:

    gs ... -dJOBSERVER - < inputfile.ps
                     -or-
    cat inputfile.ps | gs ... -dJOBSERVER -
Note: The ^D does not result in an end-of-file action on stdin as it may on some PostScript printers that rely on TBCP (Tagged Binary Communication Protocol) to cause an out-of-band ^D to signal EOF in a stream input data. This means that direct file actions on stdin such as flushfile and closefile will affect processing of data beyond the ^D in the stream.
-dNOBIND
Disables the bind operator. Useful only for debugging.
-dNOCACHE
Disables character caching. Useful only for debugging.
-dNOGC
Suppresses the initial automatic enabling of the garbage collector in Level 2 systems. (The vmreclaim operator is not disabled.) Useful only for debugging.
-dNOOUTERSAVE
Suppresses the initial save that is used for compatibility with Adobe PS Interpreters that ordinarily run under a job server. If a job server is going to be used to set up the outermost save level, then -dNOOUTERSAVE should be used so that the restore between jobs will restore global VM as expected.
-dNOSAFER (equivalent to -dDELAYSAFER).
This flag disables SAFER mode until the .setsafe procedure is run. This is intended for clients or scripts that cannot operate in SAFER mode. If Ghostscript is started with -dNOSAFER or -dDELAYSAFER, PostScript programs are allowed to read, write, rename or delete any files in the system that are not protected by operating system permissions.

This mode should be used with caution, and .setsafe should be run prior to running any PostScript file with unknown contents.

-dSAFER
Disables the deletefile and renamefile operators, and the ability to open piped commands (%pipe%cmd) at all. Only %stdout and %stderr can be opened for writing. Disables reading of files other than %stdin, those given as a command line argument, or those contained on one of the paths given by LIBPATH and FONTPATH and specified by the system params /FontResourceDir and /GenericResourceDir.

This mode also sets the .LockSafetyParams parameter of the default device, or the device specified with the -sDEVICE= switch to protect against programs that attempt to write to files using the OutputFile device parameter. Note that since the device parameters specified on the command line (including OutputFile) are set prior to SAFER mode, the -sOutputFile=... on the command line is unrestricted.

SAFER mode also prevents changing the /GenericResourceDir, /FontResourceDir and either the /SystemParamsPassword or the /StartJobPassword.

Note: While SAFER mode is not the default, in a subsequent release of Ghostscript, SAFER mode will be the default thus scripts or programs that need to open files or set restricted parameters will require the -dNOSAFER command line option.

When running -dNOSAFER it is possible to perform a save, followed by .setsafe, execute a file or procedure in SAFER mode, then use restore to return to NOSAFER mode. In order to prevent the save object from being restored by the foreign file or procedure, the .runandhide operator should be used to hide the save object from the restricted procedure.

-dSTRICT
Disables as many Ghostscript extensions as feasible, to be more helpful in debugging applications that produce output for Adobe and other RIPs.
-dWRITESYSTEMDICT
Leaves systemdict writable. This is necessary when running special utility programs such as font2c and pcharstr, which must bypass normal PostScript access protection.

Improving performance

Ghostscript attempts to find an optimum balance between speed and memory consumption, but there are some cases in which you may get a very large speedup by telling Ghostscript to use more memory.

Summary of environment variables

GS, GSC (MS Windows only)
Specify the names of the Ghostscript executables. GS brings up a new typein window and possibly a graphics window; GSC uses the DOS console. If these are not set, GS defaults to gswin32, and GSC defaults to gswin32c.
GS_DEVICE
Defines the default output device. This overrides the compiled-in default, but is overridden by any commandline setting.
GS_FONTPATH
Specifies a list of directories to scan for fonts if a font requested can't be found anywhere on the search path.
GS_LIB
Provides a search path for initialization files and fonts.
GS_OPTIONS
Defines a list of command-line arguments to be processed before the ones actually specified on the command line. For example, setting GS_DEVICE to XYZ is equivalent to setting GS_OPTIONS to -sDEVICE=XYZ. The contents of GS_OPTIONS are not limited to switches; they may include actual file names or even "@file" arguments.
TEMP, TMPDIR
Defines a directory name for temporary files. If both TEMP and TMPDIR are defined, TMPDIR takes precedence.

Debugging

The information here describing is probably interesting only to developers.

Debug switches

There are several debugging switches that are detected by the interpreter. These switches are available whether or not Ghostscript was built with the DEBUG macro defined to the compiler (refer to building a debugging configuration).

Previous to 8.10, there was a single DEBUG flag, enabled with -dDEBUG on the command line. Now there are several debugging flags to allow more selective debugging information to be printed containing only what is needed to investigate particular areas. For backward compatibilty, the -dDEBUG option will set all of the subset switches.

The -Z and -T switches apply only if the interpreter was built for a debugging configuration. In the table below, the first column is a debugging switch, the second is an equivalent switch (if any) and the third is its usage.


Switches used in debugging
Switch    Equivalent     

-A   -Z@   Fill empty storage with a distinctive bit pattern for debugging
-A-   -Z-@   Turn off -A
-Bsize       Run all subsequent files named on the command line (except for -F) through the run_string interface, using a buffer of size bytes
-B-       Turn off -B: run subsequent files (except for -F) directly in the normal way
-E   -Z#   Turn on tracing of error returns from operators
-E-   -Z-#   Turn off -E
-Ffile       Execute the file with -B1 temporarily in effect
-Kn       Limit the total amount of memory that the interpreter can have allocated at any one time to nK bytes. n is a positive decimal integer.
-Mn       Force the interpreter's allocator to acquire additional memory in units of nK bytes, rather than the default (currently 20K on DOS systems, 50K on Unix). n is a positive decimal integer, on DOS systems no greater than 63.
-Nn       Allocate space for nK names, rather than the default (normally 64K). n may be greater than 64 only if EXTEND_NAMES was defined when the interpreter was compiled .
-Zxxx
-Z-xxx
      Turn debugging printout on (off). Each of the xxx characters selects an option. Case is significant: "a" and "A" have different meanings.
0
garbage collector, minimal detail
1
type 1 and type 42 font interpreter
2
curve subdivider/rasterizer
   3
curve subdivider/rasterizer, detail
4
garbage collector (strings)
   5
garbage collector (strings, detail)
6
garbage collector (chunks, roots)
   7
garbage collector (objects)
   8
garbage collector (refs)
   9
garbage collector (pointers)
a
allocator (large blocks only)
   A
allocator (all calls)
b
bitmap image processor
   B
bitmap images, detail
c
color/halftone mapper
d
dictionary put/undef
   D
dictionary lookups
e
external (OS-related) calls
f
fill algorithm (summary)
   F
fill algorithm (detail)
g
gsave/grestore[all]
h
halftone renderer
   H
halftones, every pixel
i
interpreter, just names
   I
interpreter, everything
j
(Japanese) composite fonts
k
character cache and xfonts
   K
character cache, every access
l
command lists, bands
   L
command lists, everything
m
makefont and font cache
n
name lookup (new names only)
o
outliner (stroke)
   O
stroke detail
p
band list paths
   P
all paths
q
clipping
r
arc renderer
s
streams
   S
scanner
t
tiling algorithm
u
undo saver (for save/restore), finalization
   U
undo saver, more detail
v
alpha/transparency
   V
alpha/transparency, more detail
w
compression encoder/decoder
x
transformations
y
Type 1 hints
   Y
Type 1 hints, every access
z
trapezoid fill
#
operator error returns
%
externally processed comments
*
image and RasterOp parameters
:
command list and allocator/time summary
~
math functions and Functions
'
contexts, create/destroy
   "
contexts, every operation
^
reference counting
_
high-level output
|
(reserved for experimental code)

The following switch affects what is printed, but does not select specific items for printing:

/
include file name and line number on all trace output

These switches select debugging options other than what should be printed:

$
set unused parts of object references to identifiable garbage values
+
use minimum-size stack blocks
,
don't use path-based banding
`
don't use high-level banded images
.
use small-memory table sizes even on large-memory machines
?
validate pointers before, during and after garbage collection, also before and after save and restore; also make other allocator validity checks
@
fill newly allocated, garbage-collected, and freed storage with a marker (a1, c1, and f1 respectively)

-Txxx
-T-xxx
      Turn Visual Trace on (off). Each of the xxx characters selects an option. Case is significant: "f" and "F" have different meanings.
f
the filling algorithm with characters
F
the filling algorithm with non-character paths
h
the Type 1 hinter
s
the shading algorithm
S
the stroking algorithm

Visual Trace

Visual Trace allows to view internal Ghostscript data in a graphical form while execution of C code. Special instructions to be inserted into C code for generating the output. Client application rasterizes it into a window.

Currently the rasterization is implemented for Windows only, in clients gswin32.exe and gswin32c.exe. They open Visual Trace window when graphical debug output appears, -T switch is set, and Ghostscript was built with DEBUG option. There are two important incompletenesses of the implementation :

1. The graphical output uses a hardcoded scale. An advanced client would provide a scale option via user interface.

2. Breaks are not implemented in the client. If you need a step-by-step view, you should use an interactive C debugger to delay execution at breakpoints.


Appendix: Paper sizes known to Ghostscript

The paper sizes known to Ghostscript are defined at the beginning of the initialization file gs_statd.ps; see the comments there for more details about the definitions. The table here lists them by name and size. gs_statd.ps defines their sizes exactly in points, and the dimensions in inches (at 72 points per inch) and centimeters shown in the table are derived from those, rounded to the nearest 0.1 unit. A guide to international paper sizes can be found at

http://www.twics.com/~eds/paper/

Paper sizes known to Ghostscript
U.S. standard
         Inches        mm        Points         
Name    W  ×  H     W  ×  H     W  ×  H     

11x17   11.0  17.0  279  432  792  1224  11×17in portrait
ledger  17.0 11.0 432 279 1224 792 11×17in landscape
legal  8.5 14.0 216 356 612 1008  
letter  8.5 11.0 216 279 612 792  
lettersmall  8.5 11.0 216 279 612 792  
archE  36.0 48.0 914 1219 2592 3456  
archD  24.0 36.0 610 914 1728 2592  
archC  18.0 24.0 457 610 1296 1728  
archB  12.0 18.0 305 457 864 1296  
archA  9.0 12.0 229 305 648 864  

ISO standard

a0  33.1 46.8 841 1189 2384 3370  
a1  23.4 33.1 594 841 1684 2384  
a2  16.5 23.4 420 594 1191 1684  
a3  11.7 16.5 297 420 842 1191  
a4  8.3 11.7 210 297 595 842  
a4small  8.3 11.7 210 297 595 842  
a5  5.8 8.3 148 210 420 595  
a6  4.1 5.8 105 148 297 420  
a7  2.9 4.1 74 105 210 297  
a8  2.1 2.9 52 74 148 210  
a9  1.5 2.1 37 52 105 148  
a10  1.0 1.5 26 37 73 105  
isob0  39.4 55.7 1000 1414 2835 4008  
isob1  27.8 39.4 707 1000 2004 2835  
isob2  19.7 27.8 500 707 1417 2004  
isob3  13.9 19.7 353 500 1001 1417  
isob4  9.8 13.9 250 353 709 1001  
isob5  6.9 9.8 176 250 499 709  
isob6  4.9 6.9 125 176 354 499  
c0  36.1 51.1 917 1297 2599 3677  
c1  25.5 36.1 648 917 1837 2599  
c2  18.0 25.5 458 648 1298 1837  
c3  12.8 18.0 324 458 918 1298  
c4  9.0 12.8 229 324 649 918  
c5  6.4 9.0 162 229 459 649  
c6  4.5 6.4 114 162 323 459  

JIS standard

jisb0    1030 1456    
jisb1    728 1030    
jisb2    515 728    
jisb3    364 515    
jisb4    257 364    
jisb5    182 257    
jisb6    128 182    

ISO/JIS switchable

b0 (see * below)
b1 (see * below)
b2 (see * below)
b3 (see * below)
b4 (see * below)
b5 (see * below)

Other

flsa  8.5 13.0 216 330 612 936 U.S. foolscap
flse  8.5 13.0 216 330 612 936 European foolscap
halfletter  5.5 8.5 140 216 396 612  

*Note: Initially the B paper sizes are the ISO sizes, e.g., b0 is the same as isob0. Running the file lib/jispaper.ps makes the B paper sizes be the JIS sizes, e.g., b0 becomes the same as jisb0.


Appendix: X default font mappings

Standard X servers

Regular fonts

    AvantGarde-Book:              -Adobe-ITC Avant Garde Gothic-Book-R-Normal--\n\
    AvantGarde-BookOblique:       -Adobe-ITC Avant Garde Gothic-Book-O-Normal--\n\
    AvantGarde-Demi:              -Adobe-ITC Avant Garde Gothic-Demi-R-Normal--\n\
    AvantGarde-DemiOblique:       -Adobe-ITC Avant Garde Gothic-Demi-O-Normal--\n\
    Bookman-Demi:                 -Adobe-ITC Bookman-Demi-R-Normal--\n\
    Bookman-DemiItalic:           -Adobe-ITC Bookman-Demi-I-Normal--\n\
    Bookman-Light:                -Adobe-ITC Bookman-Light-R-Normal--\n\
    Bookman-LightItalic:          -Adobe-ITC Bookman-Light-I-Normal--\n\
    Courier:                      -Adobe-Courier-Medium-R-Normal--\n\
    Courier-Bold:                 -Adobe-Courier-Bold-R-Normal--\n\
    Courier-BoldOblique:          -Adobe-Courier-Bold-O-Normal--\n\
    Courier-Oblique:              -Adobe-Courier-Medium-O-Normal--\n\
    Helvetica:                    -Adobe-Helvetica-Medium-R-Normal--\n\
    Helvetica-Bold:               -Adobe-Helvetica-Bold-R-Normal--\n\
    Helvetica-BoldOblique:        -Adobe-Helvetica-Bold-O-Normal--\n\
    Helvetica-Narrow:             -Adobe-Helvetica-Medium-R-Narrow--\n\
    Helvetica-Narrow-Bold:        -Adobe-Helvetica-Bold-R-Narrow--\n\
    Helvetica-Narrow-BoldOblique: -Adobe-Helvetica-Bold-O-Narrow--\n\
    Helvetica-Narrow-Oblique:     -Adobe-Helvetica-Medium-O-Narrow--\n\
    Helvetica-Oblique:            -Adobe-Helvetica-Medium-O-Normal--\n\
    NewCenturySchlbk-Bold:        -Adobe-New Century Schoolbook-Bold-R-Normal--\n\
    NewCenturySchlbk-BoldItalic:  -Adobe-New Century Schoolbook-Bold-I-Normal--\n\
    NewCenturySchlbk-Italic:      -Adobe-New Century Schoolbook-Medium-I-Normal--\n\
    NewCenturySchlbk-Roman:       -Adobe-New Century Schoolbook-Medium-R-Normal--\n\
    Palatino-Bold:                -Adobe-Palatino-Bold-R-Normal--\n\
    Palatino-BoldItalic:          -Adobe-Palatino-Bold-I-Normal--\n\
    Palatino-Italic:              -Adobe-Palatino-Medium-I-Normal--\n\
    Palatino-Roman:               -Adobe-Palatino-Medium-R-Normal--\n\
    Times-Bold:                   -Adobe-Times-Bold-R-Normal--\n\
    Times-BoldItalic:             -Adobe-Times-Bold-I-Normal--\n\
    Times-Italic:                 -Adobe-Times-Medium-I-Normal--\n\
    Times-Roman:                  -Adobe-Times-Medium-R-Normal--\n\
    ZapfChancery-MediumItalic:    -Adobe-ITC Zapf Chancery-Medium-I-Normal--

Symbol fonts

    Symbol:                       -Adobe-Symbol-Medium-R-Normal--

Dingbat fonts

    ZapfDingbats:                 -Adobe-ITC Zapf Dingbats-Medium-R-Normal--

Sun OpenWindows

For Sun's X11/NeWS one can use the OpenWindows scalable fonts instead, which gives good output for any point size. In this environment, the relevant section of the resource file should look like this:

Ghostscript.regularFonts: \
    AvantGarde-Book:              -itc-avantgarde-book-r-normal-- \n\
    AvantGarde-BookOblique:       -itc-avantgarde-book-o-normal-- \n\
    AvantGarde-Demi:              -itc-avantgarde-demi-r-normal-- \n\
    AvantGarde-DemiOblique:       -itc-avantgarde-demi-o-normal-- \n\
    Bembo:                        -monotype-bembo-medium-r-normal-- \n\
    Bembo-Bold:                   -monotype-bembo-bold-r-normal-- \n\
    Bembo-BoldItalic:             -monotype-bembo-bold-i-normal-- \n\
    Bembo-Italic:                 -monotype-bembo-medium-i-normal-- \n\
    Bookman-Demi:                 -itc-bookman-demi-r-normal-- \n\
    Bookman-DemiItalic:           -itc-bookman-demi-i-normal-- \n\
    Bookman-Light:                -itc-bookman-light-r-normal-- \n\
    Bookman-LightItalic:          -itc-bookman-light-i-normal-- \n\
    Courier:                      -itc-courier-medium-r-normal-- \n\
    Courier-Bold:                 -itc-courier-bold-r-normal-- \n\
    Courier-BoldOblique:          -itc-courier-bold-o-normal-- \n\
    Courier-Oblique:              -itc-courier-medium-o-normal-- \n\
    GillSans:                     -monotype-gill-medium-r-normal-sans- \n\
    GillSans-Bold:                -monotype-gill-bold-r-normal-sans- \n\
    GillSans-BoldItalic:          -monotype-gill-bold-i-normal-sans- \n\
    GillSans-Italic:              -monotype-gill-normal-i-normal-sans- \n\
    Helvetica:                    -linotype-helvetica-medium-r-normal-- \n\
    Helvetica-Bold:               -linotype-helvetica-bold-r-normal-- \n\
    Helvetica-BoldOblique:        -linotype-helvetica-bold-o-normal-- \n\
    Helvetica-Narrow:             -linotype-helvetica-medium-r-narrow-- \n\
    Helvetica-Narrow-Bold:        -linotype-helvetica-bold-r-narrow-- \n\
    Helvetica-Narrow-BoldOblique: -linotype-helvetica-bold-o-narrow-- \n\
    Helvetica-Narrow-Oblique:     -linotype-helvetica-medium-o-narrow-- \n\
    Helvetica-Oblique:            -linotype-helvetica-medium-o-normal-- \n\
    LucidaBright:                 -b&h-lucidabright-medium-r-normal-- \n\
    LucidaBright-Demi:            -b&h-lucidabright-demibold-r-normal-- \n\
    LucidaBright-DemiItalic:      -b&h-lucidabright-demibold-i-normal-- \n\
    LucidaBright-Italic:          -b&h-lucidabright-medium-i-normal-- \n\
    LucidaSans:                   -b&h-lucida-medium-r-normal-sans- \n\
    LucidaSans-Bold:              -b&h-lucida-bold-r-normal-sans- \n\
    LucidaSans-BoldItalic:        -b&h-lucida-bold-i-normal-sans- \n\
    LucidaSans-Italic:            -b&h-lucida-medium-i-normal-sans- \n\
    LucidaSans-Typewriter:        -b&h-lucidatypewriter-medium-r-normal-sans- \n\
    LucidaSans-TypewriterBold:    -b&h-lucidatypewriter-bold-r-normal-sans- \n\
    NewCenturySchlbk-BoldItalic:  -linotype-new century schoolbook-bold-i-normal-- \n\
    NewCenturySchlbk-Bold:        -linotype-new century schoolbook-bold-r-normal-- \n\
    NewCenturySchlbk-Italic:      -linotype-new century schoolbook-medium-i-normal-- \n\
    NewCenturySchlbk-Roman:       -linotype-new century schoolbook-medium-r-normal-- \n\
    Palatino-Bold:                -linotype-palatino-bold-r-normal-- \n\
    Palatino-BoldItalic:          -linotype-palatino-bold-i-normal-- \n\
    Palatino-Italic:              -linotype-palatino-medium-i-normal-- \n\
    Palatino-Roman:               -linotype-palatino-medium-r-normal-- \n\
    Rockwell:                     -monotype-rockwell-medium-r-normal-- \n\
    Rockwell-Bold:                -monotype-rockwell-bold-r-normal-- \n\
    Rockwell-BoldItalic:          -monotype-rockwell-bold-i-normal-- \n\
    Rockwell-Italic:              -monotype-rockwell-medium-i-normal-- \n\
    Times-Bold:                   -linotype-times-bold-r-normal-- \n\
    Times-BoldItalic:             -linotype-times-bold-i-normal-- \n\
    Times-Italic:                 -linotype-times-medium-i-normal-- \n\
    Times-Roman:                  -linotype-times-medium-r-normal-- \n\
    Utopia-Bold:                  -adobe-utopia-bold-r-normal-- \n\
    Utopia-BoldItalic:            -adobe-utopia-bold-i-normal-- \n\
    Utopia-Italic:                -adobe-utopia-regular-i-normal-- \n\
    Utopia-Regular:               -adobe-utopia-regular-r-normal-- \n\
    ZapfChancery-MediumItalic:    -itc-zapfchancery-medium-i-normal-- \n
Ghostscript.dingbatFonts: \
    ZapfDingbats:                 -itc-zapfdingbats-medium-r-normal--
Ghostscript.symbolFonts: \
    Symbol:                       --symbol-medium-r-normal--

Running Ghostscript with 3d party font renderers

Font API (FAPI) is a new feature which allows to attach 3d party font renderers to Ghostscript. This section explains how to run Ghostscript with 3d party font renderers, such as Agfa UFST or Free Type.

Note: To run Ghostscript with Agfa UFST you need a license from Agfa. Please ignore issues about UFST if you haven't got it.

Important note: Third-party font renderers are incompatible with devices that can embed fonts in their output (such as pdfwrite), because such renderers store fonts in a form from which Ghostscript cannot get the necessary information for embedding. Ghostscript disables such renderers when such device is being used. In particular, UFST and Free Type are disabled while running Ghostscript with the pdfwrite device.

To run Ghostscript with Free Type, you first need to build Ghostscript with the Free Type bridge. Refer How to build Ghostscript with Free Type.

To run Ghostscript with UFST, you first need to build Ghostscript with the UFST bridge. Refer How to build Ghostscript with UFST. Both bridges may run together.

Then you need to obtain the Decoding resources from Artifex Software Inc. and install them with Ghostscript. Just copy the files to the Resource/Decoding directory (or to the subdirectory Decoding of a directory, which is specified in GenericResourcePath).

There are 2 ways to handle fonts with a 3d party font renderer (FAPI). First, you can substitute any FAPI-handled font to a PostScript font, using special map files. Second, you can redirect PostScript fonts to FAPI, setting entries in lib/FAPIconfig file.

The file lib/FAPIfontmap defines a map table for FAPI-handled fonts. The format of lib/FAPIfontmap is explained below.

Font files being handled with FAPI may reside in any directory in your hard disk. Paths to them to be specified in lib/FAPIfontmap. The path may be either absolute or relative. Relative ones are being resolved from the path, which is specified in lib/FAPIconfig file.

The file lib/FAPIfontmap is actually special PostScript code. It contains records for each font being rendered with FAPI. Records must end with semicolon. Each record is a pair. The first element of the pair is the font name (the name that PostScript documents use to access the font, which may differ from real name of the font which the font file defines). The second element is a dictionary with entries :

Key Type Description
Path string Absolute path to font file, or relative path to font file from the FontPath value, being specified in lib/FAPIconfig.
FontType interger PostScript type for this font. Only 1 and 42 are currently allowed. Note that this is unrelated to the real type of the font file - the bridge will perform a format conversion.
FAPI name Name of the renderer to be used with the font. Only /AgfaUFST and /FreeType are now allowed.
SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC. It is being ignored if Path doesn't specify a collection. Note that Free Type can't handle FCO. Default value is 0.
Decoding name (optional) The name of a Decoding resource to be used with the font. If specified, lib/xlatmap (see below) doesn't work for this font.

Example of FAPI font map record :

/FCO1 << /Path (/AFPL/Agfa/fontdata/MTFONTS/PCLPS3/MT1/PCLP3__F.fco) /FontType 1 /FAPI /AgfaUFST >> ;

Note that lib/FAPIfontmap specifies only instances of Font category. CID fonts to be listed in another map file.

The file lib/FAPIcidfmap defines a mapping table for CIDFont resources. It contains records for each CID font being rendered with FAPI. The format is similar to lib/FAPIfontmap, but dictionaries must contain few different entries :

Key Type Description
Path string Absolute path to font file, or relative path to font file from the CIDFontPath value, being specified in lib/FAPIconfig.
CIDFontType interger PostScript type for this CID font. Only 0, 1 and 2 are currently allowed. Note that this is unrelated to the real type of the font file - the bridge will perform format conversion.
FAPI name Name of the renderer to be used with the font. Only /AgfaUFST and /FreeType are now allowed.
SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC. It is being ignored if Path doesn't specify a collection. Default value is 0.
CSI array of 2 elements (required) Information for building CIDSystemInfo. The first element is a string, which specifies Ordering. The second element is a number, which specifies Supplement.

Example of FAPI CID font map record :

/HeiseiKakuGo-W5 << /Path (/WIN2000/Fonts/PMINGLIU.TTF) /CIDFontType 0 /FAPI /AgfaUFST /CSI [(Japan1) 2] >> ;

The control file lib/FAPIconfig defines 4 entries :

Key Type Description
FontPath string Absolute path to a directory, which contains fonts. Used to resolve relative paths in lib/FAPIfontmap.
CIDFontPath string Absolute path to a directory, which contains fonts to substitute to CID fonts. Used to resolve relative paths in lib/FAPIcidfmap. It may be same or different than FontPath.
HookDiskFonts array of integers. List of PS font types to be handled with FAPI. This controls other fonts that ones listed in lib/FAPIfontmap and lib/FAPIcidfmap - such ones are PS fonts installed to Ghostscript with lib/fontmap or with GS_FONTPATH, or regular CID font resources. Unlisted font types will be rendered with the native Ghostscript font renderer. Only allowed values now are 1,9,11,42. Note that 9 and 11 correspond to CIDFontType 0 and 2.
HookEmbeddedFonts array of integers. List of PS font types to be handled with FAPI. This controls fonts being embedded into a document - either fonts or CID font resources. Unlisted font types will be rendered with the native Ghostscript font renderer. Only allowed values now are 1,9,11,42. Note that 9 and 11 correspond to CIDFontType 0 and 2.

You may need to customize the file lib/xlatmap. Follow instructions in it.

Note that UFST and Free Type cannot handle some Ghostscript fonts because they does not include a PostScript interpreter and therefore has stronger restrictions on font formats than Ghostscript itself does. If their font types are listed in HookDiskFonts or in HookEmbeddedFonts, Ghostscript interpret them as PS files, then serializes font data into a RAM buffer and passes it to FAPI as PCLEOs.


Copyright © 1996-2002 artofcode LLC. All rights reserved.

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of the license contained in the file LICENSE in this distribution. For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or contact Artifex Software, Inc., 101 Lucas Valley Road #110, San Rafael, CA 94903, U.S.A., +1(415)492-9861.

Ghostscript version 8.53, 20 October 2005