Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

Harris Geospatial / Docs Center / Using IDL / Using Device Fonts


Using Device Fonts

Using Device Fonts

Device, or hardware, fonts are fonts that are provided directly by your system’s hardware or by software other than IDL. In past releases of IDL, we have used the term “hardware fonts” extensively to discuss these types of fonts. This is because in the early days of IDL, computer displays were either text-only terminals or dedicated graphics display devices such as plotters or Tektronix graphics terminals. These graphics displays generally came with a set of fonts built-in; when IDL asked the device to display characters in a built-in font, it was making a request to the hardware to display those characters.

As computer displays have become more sophisticated, the concept of fonts provided “by the hardware” has expanded to include fonts provided by the computer’s operating system, or by font-management software. For example, many computers now use font management software like Adobe Type Manager to manage the fonts made available by the operating system to all applications. We use the term “device font” to refer to a font that is available to one of IDL’s graphics devices from a source other than IDL itself. (In this case, a “graphics device” can be a Direct Graphics device as specified by the DEVICE routine.) While device fonts may include fonts only available because a particular piece of hardware knows how to draw characters in that font (a pen plotter is an example of a device that may still have its own special fonts), in most cases device fonts are fonts supplied by the operating system to any application that may want to use them.

Which Device Fonts Are Available?

To determine which device fonts are available on your system and the exact font strings to specify for each, use the GET_FONTNAMES keyword to the DEVICE Procedure. Use one of the following operating-system specific methods to determine which fonts are available:

  • UNIX — on most systems, the xlsfonts utility displays a list of fonts available to the operating system.
  • Microsoft Windows — fonts available to the system are displayed in the Fonts control panel. You may also have other fonts available if you use font-management software such as Adobe Type Manager.

Using Device Fonts

To use the Device font system with IDL Direct Graphics, either set the value of the IDL system variable !P.FONT equal to 0 (zero), or set the FONT keyword to one of the Direct Graphics routines equal to 0.

Once the Device font system is selected, use the SET_FONT keyword to the DEVICE routine to select the font to use. Because device fonts are specified differently on different platforms, the syntax of the fontname string depends on which platform you are using.


Usually, the window system provides a directory of font files that can be used by all applications. List the contents of that directory to find the fonts available on your system. The size of the font selected also affects the size of vector drawn text. On some machines, fonts are kept in subdirectories of /usr/lib/X11/fonts. You can use the xlsfonts command to list available X Windows fonts.

For example, to select the font 8X13:

!P.FONT = 0

Microsoft Windows

The SET_FONT keyword should be set to a string with the following form:

!P.FONT = 0
DEVICE, SET_FONT="font*modifier1*modifier2*...modifiern"

where the asterisk (*) acts as a delimiter between the font’s name (font) and any modifiers. The string is not case sensitive. Modifiers are simply “keywords” that change aspects of the selected font. Valid modifiers are:

  • For font weight: THIN, LIGHT, BOLD, HEAVY
  • For font quality: DRAFT, PROOF
  • For font pitch: FIXED, VARIABLE
  • For font angle: ITALIC
  • For strikeout text: STRIKEOUT
  • For underlined text: UNDERLINE
  • For font size: Any number is interpreted as the font height in pixels.

For example, if you have Garamond installed as one of your Windows fonts, you could select 24-pixel cell height Garamond italic as the font to use in plotting. The following commands tell IDL to use hardware fonts, change the font, and then make a simple plot:

!P.FONT = 0

This feature is compatible with TrueType and Adobe Type Manager (and, possibly, other type scaling programs for Windows). If you have TrueType or ATM installed, the TrueType or PostScript outline fonts are used so that text looks good at any size. See SET_FONT for more information.

Note: If you set the output device to PostScript (SET_PLOT, 'PS'), attempting to use the (*) delimiter with SET_PLOT will cause an error. You must use SET_PLOT with specific PostScript font strings as described in the following section.

Fonts and the PostScript Device

A special set of device fonts are available when the current Direct Graphics device is PS (PostScript). IDL includes font metric information for 35 standard PostScript fonts, and can create PostScript language files that include text in these fonts. (The 35 fonts known to IDL are listed in the following table; theses are standard fonts included in memory in the vast majority of modern PostScript printers.) The PostScript font metric files (*.afm files) are located in the resource/fonts/ps subdirectory of the IDL directory.

Using PostScript Fonts

To use a PostScript font in your Direct Graphics output, you must first specify that IDL use the device font system, then switch to the PS device, then choose a font using the SET_FONT keyword to the DEVICE procedure.

The following IDL commands choose the correct font system (0 designates the device font system), set the graphics device, select the font Palatino Roman, open a PostScript file to print to, plot a simple data set, and close the PostScript file:

!P.FONT = 0
DEVICE, SET_FONT='Palatino-Roman', FILE='testfile.ps'
PLOT, INDGEN(10), TITLE = 'My Palatino Title'

Allowable values for the SET_FONT keyword are listed in the following table.

Note: Subsequent PostScript output will continue to use the font Palatino Roman until you explicitly change the font again, or exit IDL.

Note: When using SET_FONT with the PostScript device on Windows, you cannot use the (*) delimiter to specify font characteristics. You must use the names shown in the following table, without modifiers.

You can also specify PostScript fonts using a set of keywords to the DEVICE procedure. The keyword combinations for the fonts included with IDL are listed in the following table. For example to use the PostScript font Palatino Bold Italic, you could use either of the following DEVICE commands:

DEVICE, SET_FONT = 'Bookman-LightItalic'

Below are the standard 35 PostScript fonts:

PostScript Font

DEVICE Keywords







































































Changing the PostScript Font Assigned to an Index

You can change the PostScript font assigned to a given font index using the FONT_INDEX keyword to the DEVICE Procedure. Font indices and their use are discussed in Embedded Formatting Commands. There is a slot available for a user-defined font (index number 20). However, any index from 3 to 20 can contain a user-defined font. See Adding Your Own PostScript Fonts for details.

After choosing the PostScript device using SET_PLOT, 'PS', you can see which fonts are associated with the available index numbers by typing HELP, /DEVICE at the command line. You can add default fonts or user-defined fonts to the font mapping list. In the following example, a font that is not mapped to a font index number by default (but is a standard PostScript font) is associated with index number 20 and used in the plot title.

DEVICE, SET_FONT = 'ZapfChancery-MediumItalic', FONT_INDEX=20
PLOT, INDGEN(10), TITLE='!20Simple Plot Example'

View the default idl.ps file to see the results.

Changing the font index assigned to a font can be useful when changing PostScript fonts in the middle of a text string. For example, the following statements map Palatino Bold Italic to font index 4, and then output text using that font and the Symbol font:

; Map the font selected by !4 to be PalatinoBoldItalic:
; Output "Alpha :" in PalatinoBoldItalic followed by an 
; Alpha character:
XYOUTS, .3, .5, /NORMAL, "!4Alpha: !9a", FONT=0, SIZE=5.0

Adding Your Own PostScript Fonts

Because the 35 PostScript fonts included with IDL are built in to a PostScript printer’s memory, the IDL distribution includes only the font metric files, which provide positioning information. In addition, the .afm files used by IDL are specially processed to provide the information in a format IDL expects.

You can add your own PostScript fonts to the list of fonts known to IDL if you have access to the PostScript font file (usually named font.pfb) to load into your printer and to the font.afm file supplied by Adobe. You can convert the standard .afm file into a file IDL understands using the IDL routine PSAFM. Consult the file README.TXT in the resource/fonts/ps subdirectory of the IDL directory for details on adding PostScript fonts to your system. In general, you will need to do the following:

  1. Add the font to the resource/fonts/ps subdirectory of the IDL directory using PSAFM.
  2. Add an entry for the font to the fonts.map file located in the resource/fonts/ps directory. You can locate the required fontname by examining the font file in a text editor.
  3. Use the font directly by calling it with SET_FONT or add it to the list of font mappings using FONT_INDEX. See Changing the PostScript Font Assigned to an Index for details.

© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us