4 Fonts

4.1 Characteristics of fonts

Fonts contain character images and are used to display text output on bitmaps. A discussion of bitmaps and functions that support text output can be found in Chapter 2, "Bitmaps, Viewports, and Windows".

Fonts are stored in a font registry from which they can be accessed at any time. All fonts have a height, a width, and a baseline.

All character images in a font have the same height. The function font-height returns the height of a specific font.

(font-height *default-font*)
The variable *default-font* contains the default font that the Window Tool Kit uses in text output. The function stream-current-font returns the current font of a bitmap output stream. The variable *default-pop-up-menu-font* contains the default font that is used for pop-up menus. You can use the Common Lisp special formsetq to change the value of these variables. To find the height of a particular character in the font, use the function char-height.

A font can be a fixed-width font or a variable-width font. In a fixed-width font, each character has the same width. For example, lowercasei and uppercaseW have the same width in a fixed-width font. In a variable-width font, characters can have different widths, so the lowercase letter is not as wide as the uppercase one. The function char-width returns the width of a particular character in a font, and the function max-char-width returns the maximum character width a font can support.

The function font-fixed-width returns the font width for fixed-width fonts.

(font-fixed-width *default-font*)
The font baseline is the horizontal line on which characters in the font are positioned. Most characters in a font have an ascender, which is the part of the character above the baseline. Some characters, such asj andq, also have a descender, which is the part of the character below the baseline. The height of a font is the combined height of its ascender and descender. The function font-baseline returns the bit position of the font's baseline relative to the top of the character.


The Window Tool Kit - 9 SEP 1996

Generated with Harlequin WebMaker