Coyote's Guide to IDL Programming

Using PostScript Fonts

QUESTION: How can I use PostScript fonts in my output?

ANSWER: PostScript fonts are different from the normal IDL fonts. If you don't know this, you will wonder why your PostScript output is different from what you see on your display.

Normally, IDL uses Hershey fonts for its display fonts. These are vectorized or software fonts. The great advantage of vector fonts is that they are device independent and can be scaled and rotated in 3D space in an easy and efficient manner. The disadvantage to Hershey fonts is that they don't look as nice as true PostScript fonts on your hardcopy output. Many people think they look a little bit thin compared to PostScript fonts.

You can easily switch to PostScript or hardware fonts by setting the !P.FONT system variable to 0 (the normal default is -1), or by setting the FONT keyword on a graphics display command to 0. For example, to output a plot with the PostScript Helvetica font active, you do this:

   PLOT, data, FONT=0, TITLE='Normal Plot with Helvetica Type'

You must realize, however, that PostScript fonts are seldom, if ever, the same size as corresponding Hershey fonts. Thus, using PostScript fonts changes the way text is positioned with respect to other graphics elements in the output. You can minimize these differences by taking care how you position text in your display. For example, whenever possible I try to center text about a particular point. This way if the PostScript font is slightly larger than the display font, no damage is done to my graphic display. For example, I might position the display title like this:

   displayTitle = 'My Important Work'
   XYOUTS, 0.5, 0.95, displayTitle, SIZE=3.0, ALIGNMENT=0.5

Mapping IDL Fonts to PostScript Fonts

There is a default mapping of Hershey fonts to PostScript fonts. For example, the normal Hershey Simplex Roman font is mapped to Helvetica. The normal Hershey Math font is mapped to the PostScript Symbol font, etc. You can see a listing of the default font mapping, by typing this:


You can also assign a different font mapping. For example, suppose you prefer the Times font to be the default mapping for the Hershey Simplex Roman font. With the PostScript device active, you can type this:


Use IDL Fonts in 3D Space

Note that PostScript fonts do not rotate in 3D space the way Hershey fonts do. If you have surface plots in your output, you will want to be sure to use Hershey fonts and not PostScript fonts. Or, you can use True-Type fonts, which also rotate in 3D space, since they are just filled polygons. Normally, True-Type fonts are slightly smaller than the equivalent Hershey or PostScript font, so the character size has to be increased a little.

You could use commands similar to this to create a surface plot with rotated True-Type fonts.

   Device, Set_Font='Times', /TT_Font
   setup = PSConfig(/NoGUI)
   thisDevice = !D.Name
   Set_Plot, 'PS'
   Device, _EXTRA=setup
   Surface, Dist(64), Font=1, Charsize=2.0
   Device, /Close
   Set_Plot, thisDevice

Executing this code in IDL will give you something like the figure below (which is only a representation of the PostScript ouput). The PSCONFIG program is a Coyote Library program.

Postscript Output.
PostScript output with rotating True-Type fonts.

Web Coyote's Guide to IDL Programming