Demos · Utilities · Applications · Books · Links


Depth Depth

Rotate with Shadow Rotate with Shadow

Mandelbrot Mandelbrot

Growth Growth

Phyllotaxis Phyllotaxis

Weird typesetting Weird typesetting

ASCII Tux, also in PDF


Browsing font samples

Loosing track of all the fonts you installed for Ghostscript?
You know the font you need must be there, but you can't remember how it is called?

Here is a solution to your problem, if you work with Linux or some other Unix. A few scripts that generates a set of HTML files, listing examples of all your installed fonts, with links to demos of the full character set of individual fonts:

Editing PostScript with GNU Emacs

ps-mode.el (© Free Software Foundation, Inc.) is a GNU Emacs major editing mode for PostScript. It provides simple error handling, menus, syntax-highlighting, auto-indentation, and some usefull PostScript functions.

ps-mode will be integrated in GNU Emacs version 21. If you are still using an older version of Emacs you may want to add the following to your .emacs file:
    ;; Set up autoloading and auto-mode
    (autoload 'ps-mode "ps-mode"
      "Major mode for editing PostScript" t)
    (setq auto-mode-alist
	   '(("\\.[eE]?[pP][sS]$" . ps-mode))
PostScript mode version 1.1 offers font-lock support. To switch on fontification, put this in your .emacs file (Emacs 20):
    ;; Turn on font lock, use lazy-lock for large PostScript files
    (setq font-lock-maximum-decoration t)
    (add-hook 'ps-mode-hook
	      '(lambda ()
		 (make-local-variable 'font-lock-support-mode)
		 (make-local-variable 'lazy-lock-defer-on-scrolling)
		 (setq font-lock-support-mode 'lazy-lock-mode
		       lazy-lock-defer-on-scrolling t)
    (add-hook 'ps-run-mode-hook
	      '(lambda ()

Converting PostScript to Pixelmap

ps2ppm (© P. Kleiweg) is a Perl5 script for converting PostScript to color images such as GIF. It works under Unix, using ghostscript. You might have to modify the first line of the script to make it work.

Run ps2ppm without any arguments to list permitted options.

The only requirement a PostScript file has to fulfil to enable ps2ppm to handle it properly is that the %%BoundingBox comment is correctly defined.

ps2ppm can handle multi-page images as long as all pages have the same BoundingBox. This can be demonstrated with:

    ps2ppm rshadow

The illusion of high resolution images can be created using the following steps:

  1. Create an image multiplying the default resolution of 72 by three:
        ps2ppm -r 216 file
  2. Modify the image (using e.g. xv) with the 3x3 blur algorithm
  3. Decrease the size of the image to 33%, giving it the original intended size
  4. Save the image in the file-format you need

Or you can use command line utilities often found on Unix (pnmscale does blurring by default):

    ps2ppm -r 216 file
    pnmscale .3333 file.01.ppmraw | cjpeg > file.jpg
    pnmscale .3333 file.01.ppmraw | ppmquant 256 | ppmtogif > file.gif

Another thing you could try is using the anti-aliassing capabilities of Ghostscript. You can switch them on with options -t (text) and/or -g (graphics). The results are sometimes good (even better with text), sometimes bad:

    ps2ppm -t -g file
    cjpeg file.01.ppmraw > file.jpg
    ppmquant 256 file.01.ppmraw | ppmtogif > file.gif

ps2ppm obtains the best color rendering when converting to ppm or ppmraw (the default). Converting directly to gif8, might give imperfect results.

Low resolution fonts: X fonts

The standard PostScript fonts are intended to be used on a high-resolution output device (300dpi or more). Converting to a bitmap may result in text that is hardly readable.

A solution to this problem is to use one of the many X11 fonts. (If you don't have access to a X server, read on.) These are designed for a low resolution screen (about 75dpi) and will look good when converted to bitmaps. A program that performs this conversion, even for 16 bit character sets, is:


A PostScript program can be used to test fonts created with font2ps.

When the font is created it is given the name XFont. To change this, search towards the end of the produced file for the line that reads:

/XFont exch definefont pop
The usage of these fonts is slightly different from ordinary fonts. Compare these two examples:
/Times-Roman findfont 10 scalefont setfont

(Xfont.psf) run
/XFont findfont setfont
These fonts should not be scaled. Set the resolution of the output device to exactly 72dpi for accurate results.

For those who don't have access to an X server, here are some `precompiled' fonts:

FilenamePS fontname
X11 fontname
-adobe-new century schoolbook-medium-r-normal--18-180-75-75-p-103-iso8859-1

Here are some examples:

Printing Selected Pages

Sometimes you want to print not a complete PostScript document but just some selected pages. Here are several options.

DSC Conforming Documents

In a DSC (Document Structuring Conventions) conforming document all pages are individually accessible, clearly delineated by DSC comments. You can extract the pages you want to print before you send the result to a PostScript printer or interpreter. A utility for extracting these pages is pssplit:

Non DSC Conforming Documents: PostScript Level 2

When there are no comments in the document to separate the document in pages, then the only solution is to have the entire document processed by a PostScript interpreter. However, PostScript Level 2 keeps track of the number of pages it has output, and you can redefine the output routine to tell PostScript to discard of the pages you don't want. A program that adds the necessary code to achieve this is pspages:

Non DSC Conforming Documents: Ghostscript

With Ghostscript, instead of having the output sent to a printer, you can send it to a file instead. In this case, you can tell Ghostscript to divide the output in one file per page. Then you can copy the files you want to the printer. Here is an example:
gs -r300 -sDEVICE=djet500 -sOutputFile=file.%03d -dNOPAUSE -c quit
This will produce files like file.001, file.002, etc.

Curves with arrows and labels

Several functions to draw lines and curves with arrowheads and labels can be found in the demo



Teach yourself PostScript within a few hours:

Essential reference guide, not suited as a tutorial: