The vector fonts used by IDL were digitized by Dr. A.V. Hershey of the Naval Weapons Laboratory. Characters in the vector fonts are stored as equations, and can be scaled and rotated in three dimensions. They are drawn as lines on the current graphics device, and are displayed quickly and efficiently by IDL. The vector fonts are built into IDL itself, and are always available.
All the available fonts are illustrated in Vector Font Samples. The default vector font (Font 3, Simplex Roman) is in effect if no font changes have been made.
To use the vector font system with IDL Direct Graphics, either set the value of the IDL system variable
Once the vector font system is selected, use an embedded formatting command to select a vector font (or fonts) for each string. (See Embedded Formatting Commands for details on embedded formatting commands.) The font selected "sticks" from string to string; that is, if you change fonts in one string, future strings will use the new font until you change it again or exit IDL.
For example, to use the Duplex Roman vector font for the title of a plot, you would use a command that looks like this:
PLOT, mydata, TITLE="!5Title of my plot"
Consult Using IDL for details on using the vector font system with IDL Object Graphics.
To specify the size of a vector 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 letters based on an "average" character that is 70 pixels wide, with 90 pixels between lines:
DEVICE, 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 |
The default font (Font 3, Simplex Roman) follows the ISO Latin 1 Encoding scheme and contains many international characters. The illustration of this font under Vector Font Samples can be used to find the octal codes for the special characters.
For example, suppose you want to display some text with an Angstrom symbol in it. Looking at the chart of font 3, we see that the Angstrom symbol has octal code 305. Non-printable characters can be represented in IDL using octal or hexadecimal notation and the STRING function (see Representing Non-Printable Characters for details). So the Angstrom can be printed by inserting a STRING("305B) character in our text string as follows:
XYOUTS,.1, .5, 'Here is an Angstrom symbol: ' + STRING("305B), $
/NORM, CHARSIZE=3
The EFONT procedure is a widget application that allows you to edit the Hershey fonts and save the results. Use this routine to add special characters or completely new, custom fonts to the Hershey fonts.