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 either a Direct Graphics device as specified by the DEVICE routine or an Object Graphics "destination" such as a window or a printer.) 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.
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. You can also use an operating system specific method to determine which fonts are available:
On most systems, the xlsfonts utility displays a list of fonts available to the operating system.
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.
To use the Device font system with IDL Direct Graphics, either set the value of the IDL system variable
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 DEVICE, SET_FONT = '8X13'
The SET_FONT keyword should be set to a string with the following form:
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 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 DEVICE, SET_FONT = "GARAMOND*ITALIC*24" PLOT, FINDGEN(10), TITLE = "IDL Plot"
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.
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; they the 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.
To use a PostScript font in your Direct Graphics output, you must first specify that IDL use the device font system, they 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, 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 SET_PLOT, 'PS' DEVICE, SET_FONT = 'Palatino-Roman', FILE = 'testfile.ps' PLOT, INDGEN(10), TITLE = 'My Palatino Title' DEVICE, /CLOSE
| Note |
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 = 'Palatino*Bold*Italic' DEVICE, /PALATINO, /BOLD, /ITALIC
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.
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: DEVICE, /PALATINO, /BOLD, /ITALIC, FONT_INDEX=4 ; Output "Alpha :" in PalatinoBoldItalic followed by an ; Alpha character: XYOUTS, .3, .5, /NORMAL, "!4Alpha: !9a", FONT=0, SIZE=5.0
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.