Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
_SetFont Function
◄Summary► ◄Details► ◄Example► ◄Back►
Argument
options CSTRING specifying font characteristics
Returns
Integer Font number if successful; otherwise, a negative number
Description
The _SetFont procedure searches the set of registered fonts for a
font with the characteristics specified by the options string. If
a matching font is found, it becomes the current font for output
with _OutGText, and the font number is returned.
The options string is a set of characters that specifies the
desired font characteristics. Characteristics that may be
specified are listed below. The command characters are neither
case nor position sensitive.
Characteristic Description
══════════════ ═══════════════════════════════════════════════
t ''fontname'' Typeface
h<number> Character height in number of pixels
w<number> Character width in number of pixels
f Fixed-space font (should not be used with p)
p Proportionally spaced font (should not be used
with f)
v Vector font (should not be used with r)
r Raster (bit-mapped) font (should not be used
with v)
b Best-fit font
n<number> Font number, where <number> is greater than 0
and less than or equal to the value returned by
the _RegisterFonts function
In general, as many options may be requested as desired. If mutually
exclusive options are requested, such as the pair f/p or r/v,
_SetFont ignores them.
For vector fonts, _SetFont allows the h and w options to be used
with the n option. It ignores other options used with n for vector
fonts and ignores any options used with n for raster fonts.
Options can be separated in the option string by blanks. Characters
other than those listed above are ignored. The typeface
specification in the option string is specified as a T, followed
by the type name in single quotes. To embed single quotes inside
Pascal strings, follow the closing quote with another single quote.
The typeface name may be any of the following valid fonts:
Type Name Description
═════════ ══════════════════════════════════════════════
Courier Fixed-width bit-mapped font with serifs
Helv Proportional bit-mapped font without serifs
Tms Rmn Proportional bit-mapped font with serifs
Script Proportional vector-mapped font of slanted
characters formed from nearly continuous lines
Modern Proportional vector-mapped font without serifs
Roman Proportional vector-mapped font with serifs
A b in the option field causes _SetFont to automatically select
the "best fit" font -- the one providing the best match to
specified characteristics. If the b parameter is specified and at
least one font is registered, _SetFont can always set a font and
will return the font number to indicate success.
In selecting a font, _SetFont uses the following precedence:
1. Pixel height
2. Typeface
3. Pixel width
4. Fixed or proportional font
A smaller font takes precedence over a larger, given two choices
equally close to the requested size. If _SetFont requests Helv 12
with best fit, and only Helv 10 and Helv 14 are available, _SetFont
will select Helv 10.
The n option can be used for cycling through all registered fonts.
Because .FON files often contain several fonts and files are loaded
into memory in the reverse order in which they were registered, it
is sometimes difficult to know which font will be the given number.
If successful, however, _SetFont returns the number of the selected
font, which can be used with the n parameter on subsequent calls to
_SetFont.
If nonexistent values are chosen for pixel height and width,
_SetFont will apply a magnification factor to a vector-mapped
font to obtain a suitable font size. However, this automatic
magnification is inapplicable if the raster-mapped font (r) option
is specified, or if a particular typeface is requested and no
best-fit (b) option is specified.
Note: The font functions affect only the output from _OutGText;
no other output functions are affected.
An error occurs if a request for a specific font fails and
option b was not specified. An error also occurs if no fonts have
been registered, or if there is insufficient memory to load
the font. If _SetFont fails, it returns a negative number. Use
_GrStatus to determine the nature of the error.
_GrStatus Returns
_GrError, _GrFontFileNotFound, _GrInsufficientMemory,
_GrParameterAltered