Controlling Size, Position and Font Use
The way font size is set depends upon the type of font and whether the font is being rendered in Direct or Object Graphics. See one of the followings:
- Direct Graphics — See Controlling Size, Position and Font Use
- Object Graphics — See Fonts (Object Programming)
You can control the position of individual characters, and the font with which individual characters in a text string are rendered by using embedded formatting commands. See Embedded Formatting Commands for details.
Specifying Font Size
The size of a device font is specified when the font is defined. See Using Device Fonts for details. The size of a Hershey vector or TrueType font is specified by using 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
While the first element of the vector specified to SET_CHARACTER_SIZE is technically a width, it is important to note that the width value has no effect on the widths of individual characters in the font. The width value is used only to calculate the appropriate scaling factor for the font.
For example, the following IDL commands display the word "Hello There" on the screen in Courier Bold Italic, in letters based on an "average" character that is 70 pixels wide, with 90 pixels between lines. Use FONT=1 to specify the TrueType font system:
DEVICE, SET_FONT='Courier Bold Italic', /TT_FONT, $ SET_CHARACTER_SIZE=[70,90] XYOUTS, 0.1, 0.5, 'Hello!CThere', FONT=1
The same example can be replicated using Hershey vector fonts. To use a vector font, specify the font using an embedded formatting command (explained in detail in Embedded Formatting Commands). For example, to display the text in Triplex Italic, Hershey vector font number 18, use !18 at the beginning of the string. As the vector font system is the default, you do not need to use the FONT keyword to XYOUTS.
To return to using the default Helvetica font, change !18 to !3:
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:
Note that changing the CHARSIZE adjusts both the character size and the space between lines.