Beginning with version 5.2, five TrueType font families are included with IDL. The fonts included are:
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:
To use the TrueType font system with IDL Direct Graphics, either set the value of the IDL system variable
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.
To specify the size of a TrueType font, use the SET_CHARACTER_SIZE keyword to the DEVICE procedure. The SET_CHARACTER_SIZE keyword takes a two-element vector as its argument. The first element specifies the width of the "average" character in the font (in pixels) and calculates a scaling factor that determines the height of the characters. (It is not important what the "average" character is; it is used only to calculate a scaling factor that will be applied to all of the characters in the font.) The second element of the vector specifies the number of pixels between baselines of lines of text.
The ratio of the "average" character's height to its width differs from font to font, so specifying the same value [x, y] to the SET_CHARACTER_SIZE keyword may produce characters of different sizes in different fonts.
| Note |
For example, the following IDL commands display the word "Hello There" on the screen in Helvetica Bold, in letters based on an "average" character that is 70 pixels wide, with 90 pixels between lines:
DEVICE, FONT='Helvetica Bold', /TT_FONT, SET_CHARACTER_SIZE=[70,90] XYOUTS, 0.1, 0.5, 'Hello!CThere'
You can also use the CHARSIZE keyword to the graphics routines or the CHARSIZE field of the !P System Variable to change the size of characters to a multiple of the size of the currently-selected character size. For example, to create characters one half the size of the current character size, you could use the following command:
XYOUTS, 0.1, 0.5, 'Hello!CThere', CHARSIZE=0.5
Note that changing the CHARSIZE adjusts both the character size and the space between lines.
Embedded formatting commands allow you to position text and change fonts within a single line of text. A subset of the embedded formatting commands available for use with the vector fonts are also available when using the TrueType font system. See Embedded Formatting Commands for a list of in-line formatting commands.
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), 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).
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 |
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.
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:
No further search will be performed. If the specified font is not included in the ttfont.map file, IDL will substitute Helvetica.
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.