The Types of Fonts

Windows supports two broad categories of fonts, called ”GDI fonts“ and ”device fonts.“

The GDI-based fonts are stored in files with the extension .FON. These files are sometimes called ”font resource files,“ and they are stored in the SYSTEM subdirectory of your Windows directory. Each file contains one or more complete fonts. These files are in New Executable format, which you can verify by running EXEHDR on them. They are library modules, although somewhat unusual ones in that they contain no code or data. All they contain are two types of resources: a font directory and the fonts themselves.

Device fonts are internal to the graphics output device. For video display adapters, device fonts are currently rare. Windows uses the video adapter in graphics mode, so it must use the GDI fonts and write the pixels to the video display.

For printers, however, device-based fonts are common. For instance, Windows can write text to a dot-matrix printer using either the printer's normal text mode or the printer's graphics mode. With the text mode, Windows uses a device font and needs to send only the ASCII numbers of the characters out to the printer. With the graphics mode, Windows uses a GDI font and must send the pixel patterns to the printer. For laser printers, device fonts can be stored in ROM within the printer or in ROM cartridges. If the printer requires a downloadable font that originates from a disk file, this font is also classified as a device font, because it is specific to the particular device.

GDI fonts come in two flavors—”raster,“ or bitmap, fonts (the more common variety) and ”stroke“ fonts. In a raster font file, each character is stored as a bitmap pixel pattern. Figure 14-1 shows a character from a GDI raster font, blown up so that you can see the pixel formation.

Each raster font is designed for a specific aspect ratio and character size. Windows can create larger character sizes from GDI raster fonts by simply duplicating rows or columns of pixels. However, this can be done only in integral multiples and within certain limits. Right away, you can probably perceive one major difference between drawing graphics on the display and writing text to the display using the GDI raster fonts. Although you can draw a rectangle of virtually any size, GDI raster fonts are available only in discrete sizes. You can't write text using a font smaller than the smallest font. If you want a GDI raster font of a specific size, that size may not be available.

The GDI stroke fonts partly solve this problem. The stroke fonts are defined as a series of line segments in a ”connect-the-dots“ format. Stroke fonts are continuously scalable, which means that the same font can be used for all aspect ratios and can be increased or decreased to any size. In general, GDI raster fonts look better than stroke fonts at small sizes because raster font designs were based on small sizes. At very large sizes, however, the raster fonts look grainy—as you can see in Figure 14-1—because Windows has to start doubling rows or columns of pixels. Thus, the stroke fonts are usually preferable for large sizes, although the characters look somewhat weak because their strokes are single lines. Figure 14-2 shows a character from a blown-up GDI stroke font.

For both GDI raster fonts and stroke fonts, Windows can ”synthesize“ boldface, italics, underlining, and strikethrough without storing separate fonts for each attribute. For italics, for instance, Windows simply shifts the upper part of the character to the right. Because device fonts are stored and used in a device-specific manner, it is impossible to discuss them in the same detail as GDI fonts. Sometimes the device can italicize or boldface a device font, and sometimes it can't. You can obtain such information from the GetDeviceCaps function using the TEXTCAPS index. If you want to obtain this information for particular printers, you can use the GetDeviceCaps function as illustrated in the DEVCAPS1 program in Chapter 11.