6.11  font-name-directory<%>

There is one font-name-directory<%> object: the-font-name-directory. It implements the mapping from font specifications (face, family, style, and weight) to information for rendering text on a specific device. The mapping is different for each platform. For example, when drawing to a bitmap in Windows, the rendering information is simply the name of a Windows font. When drawing to a PostScript file, the rendering information is a PostScript font name, which encapsulates the style and weight. When drawing to a bitmap in X, the rendering information is an X font string, which encapsulates the style and weight, parameterized over the size (using a ``%d'' placeholder).

Programmers rarely need to directly invoke methods of the-font-name-directory. It is used automatically when drawing text to a dc<%> object. Nevertheless, the-font-name-directory is available so that programmers can query or modify the mapping manually. A programmer may also need to understand how the face-and-family mapping works.

To extract mapping information from the-font-name-directory, first obtain a font ID, which is an index based on a family and and optional face string. Font IDs ar returned by find-or-create-font-id and get-font-id . A Font ID can be combined with a weight and style to obtain a specific mapping value via get-screen-name or get-post-script-name.

For a family without a face string, the corresponding font ID has a useful built-in mapping for every platform and device. (The built-in mapping can be overridden through the user's preferences; see Font Preferences for information.) For a family with a face string, the-font-name-directory interprets the string (in a platform-specific way) to generate a mapping for ``screen'' drawing (to a canvas's dc<%>, a bitmap-dc%, or a printer-dc%). When drawing to a post-script-dc% object, the face-specific mapping defaults to the family's mapping.

Under Windows and Mac OS, a face name is interpreted simply as a system font name for drawing to the screen, bitmap, or printer. The mapping succeeds if the system provides a font with the given name, and fails otherwise. For example, under Windows, "MS Sans Serif" maps to the font that is typically used for button labels. Under X, a face name has a more complex interpretation:

The mapping for face names can be overridden (on all platforms) through the user's preferences, as described in Font Preferences.