Call the function _setfont to select a current font. This function checks to see if the requested font is registered, then reads the mapping data from the appropriate .FON file. A font must be registered and marked current before your program can display text in that font.
The GRAPH.H file prototypes the_setfont function as
short far _setfont( unsigned char far * );
The function's argument is a pointer to a character string. The string consists of letter codes that describe the desired font, as outlined here:
Option Code | Meaning |
b | The best fit from the registered fonts. This option instructs _setfont to accept the closest-fitting font if a font of the specified size is not registered. |
If at least one font is registered, the b option always sets a current font. If you do not specify the b option and an exact matching font is not registered, the _setfont function will fail. In this case, any existing current font remains current. Refer to Help for a description of error codes returned by_setfont. | |
The _setfont function uses four criteria for selecting the best fit. In descending order of precedence, the four criteria are pixel height, typeface, pixel width, and spacing (fixed or proportional). If you request a vector-mapped font, _setfont sizes the font to correspond with the specified pixel height and width. If you request a raster-mapped (bit-mapped) font, _setfont chooses the closest available size. If the requested type size for a raster-mapped font fits exactly between two registered fonts, the smaller size takes precedence. | |
f | Fixed-spaced font. |
hy | Character height, where y is the height in pixels. |
nx | Font number x, where x is less than or equal to the value returned by _registerfonts. For example, the option n3 makes the third registered font current, if three or more fonts are registered. |
p | Proportional-spaced font. |
r | Raster-mapped (bit-mapped) font. |
t`fontname' | Typeface of the font in single quotes. The fontname string is one of the following: courier modern helv script tms rmn roman Note the space in tms rmn. Additional font files use other names for fontname. Refer to the vendor's documentation for these names. |
v | Vector-mapped font. |
wx | Character width, where x is the width in pixels. |
Option codes are not case sensitive and can be listed in any order. You can separate codes with spaces or any other character that is not a valid option code. The _setfont function ignores all invalid codes.
The _setfont function updates a data area with parameters of the current font. The data area is in the form of a structure, defined in GRAPH.H as follows:
struct _fontinfo
{
int type; /* set = vector,clear = bit map */
int ascent; /* pix dist from top to base */
int pixwidth; /* character width in pixels */
int pixheight; /* character height in pixels */
int avgwidth; /* average character width */
char filename[81]; /* file name including path */
char faceName[32]; /* font name */
};
If you want to retrieve the parameters of the current font, call the function _getfontinfo.