About TrueType Fonts

Figure H-11: TrueType Font

fonttrue.gif

Beginning with version 5.2, IDL includes the following five TrueType font families:

Table H-31: TrueType Font Names

Font Family
Italic
Bold
BoldItalic

Courier

Courier Italic

Courier Bold

Courier Bold Italic

Helvetica

Helvetica Italic

Helvetica Bold

Helvetica Bold Italic

Monospace Symbol

Times

Times Italic

Times Bold

Times Bold Italic

Symbol

When TrueType fonts are rendered on an IDL graphics device or destination object, the font outlines are first scaled to the proper size. After scaling, IDL converts the character outline information to a set of polygons using a triangulation algorithm. When text in a TrueType font is displayed, IDL is actually drawing a set of polygons calculated from the font information. This process has two side effects:

  1. Computation time is used to triangulate and create the polygons. This means that you may notice a slight delay the first time you use text in a particular font and size. Once the polygons have been created, the information is cached by IDL and there is no need to re-triangulate each time text is displayed. Subsequent uses of the same font and size happen quickly.
  2. Because the TrueType font outlines are converted into polygons, you may notice some chunkiness in the displayed characters, especially at small point sizes. The smoothness of the characters will vary with the quality of the TrueType font you are using, the point size, and the general smoothness of the font outlines.

Using TrueType Fonts

To use the TrueType font system with IDL Direct Graphics, either set the value of the IDL system variable !P.FONT equal to 1 (one), or set the FONT keyword to on one of the Direct Graphics routines equal to 1. Consult Creating Font Objects (Object Programming) for information on using the TrueType font system with IDL Object Graphics.

Once the TrueType font system is selected, use the SET_FONT keyword to the DEVICE routine to select the font to use. The value of the SET_FONT keyword is a font name string. The font name is the name by which IDL knows the font; the names of the TrueType fonts included with IDL are listed under About TrueType Fonts. Finally, specify the TT_FONT keyword in the call to the DEVICE procedure. For example, to use Helvetica Bold Italic, use the following statement:

DEVICE, SET_FONT='Helvetica Bold Italic', /TT_FONT 

To use Times Roman Regular:

DEVICE, SET_FONT='Times', /TT_FONT 

IDL's default TrueType font is 12 point Helvetica regular.

Also see the following to modify the characteristics of a TrueType font:

IDL TrueType Font Resource Files

The TrueType font system relies on a resource file named ttfont.map, located in the resource/fonts/tt subdirectory of the IDL directory. The format of the ttfont.map file is:

FontName    FileName    DirectGraphicsScale    ObjectGraphicsScale 

where the fields in each column must be separated by white space (spaces and/or tabs). The fields contain the following information

The Fontname field contains the name that would be used for the SET_FONT keywords to the DEVICE routine.

The Filename field contains the name of the TrueType font file. On UNIX platforms, IDL will search for the file specified in the FileName field in the current directory (that is, in the resource/fonts/tt subdirectory of the IDL directory) if a bare filename is provided, or it will look for the file in the location specified by the fully-qualified file name if a complete path is provided. Because different platforms use different path-specification syntax, we recommend that you place any TrueType font files you wish to add to the ttfont.map file in the resource/fonts/tt subdirectory of the IDL directory. On Windows platforms, this entry may be '*', in which case the font will be loaded from the operating system font list, but that the following two scale entries will be honored.

The DirectGraphicsScale field contains a correction factor that will be applied when choosing a scale factor for the glyphs prior to being rendered on a Direct Graphics device. If you want the tallest character in the font to fit exactly within the vertical dimension of the device's current character size (as set via the SET_CHARACTER_SIZE keyword to the DEVICE procedure, described in Specifying Font Size), set the scale factor equal to 1.0. Change the scale factor to a smaller number to scale a smaller portion of the tallest character into the character size.

For example, suppose the tallest character in your font is "Ã". Setting the scale factor to 1.0 will scale this character to fit the current character size, and then apply the same scaling to all characters in the font. As a result, the letter "M" will fill only approximately 85% of the full height of the character size. To scale the font such that the height of the "M" fills the vertical dimension of the character size, you would include the value 0.85 in the scale field of the ttfont.map file.

The ObjectGraphicsScale field contains a correction factor that will be applied when choosing a scale factor for the glyphs prior to being rendered on a Object Graphics device. (This field works just like the DirectGraphicsScale field.) This scale factor should be set to 1.0 if the maximum ascent among all glyphs within a given font is to fit exactly within the font size (as set via the SIZE property to the IDLgrFont object).

Adding Your Own Fonts

To add a your own font to the list of fonts known to IDL, use a text editor to edit the ttfont.map file, adding the FontName, FileName, DirectGraphicsScale, and ObjectGraphicsScale fields for your font. You will need to restart IDL for the changes to the ttfont.map file to take effect. On Windows systems, you can use fonts that are not mentioned in the ttfont.map file, as long as they are installed in the Fonts control panel, as described below.

Warning
If you choose to modify the ttfont.map file, be sure to keep a backup copy of the original file so you can restore the defaults if necessary. Note also that applications that use text may appear different on different platforms if the scale entries in the ttfont.map file have been altered.

Where IDL Searches for Fonts

The TrueType font files included with IDL are located in the resource/fonts/tt subdirectory of the IDL directory. When attempting to resolve a font name (specified via the FONT keyword to the DEVICE procedure), IDL will look in the ttfont.map file first. If it fails to find the specified font file in the ttfont.map file, it will search for the font file in the following locations:

UNIX

No further search will be performed. If the specified font is not included in the ttfont.map file, IDL will substitute Helvetica.

Microsoft Windows

If the specified font is not included in the ttfont.map file, IDL will search the list of fonts installed in the system (the fonts installed in the Font control panel). If the specified font is not found, IDL will substitute Helvetica.

Note
To get the list, you can use the following command, which returns in the variable fnames the names of all available fonts:

   DEVICE, GET_FONTNAMES=fnames, SET_FONT='*'