2.3.11 font-name-directory<%>

► |  | GUI: Racket Graphics Toolkit

1 | Overview
2 | Reference
3 | Configuration
4 | Dynamic Loading
| Bibliography
| Index

► | 2 | Reference

2.1 | Windowing Classes
2.2 | Windowing Functions
2.3 | Drawing Classes
2.4 | Drawing Functions
2.5 | Editor Classes
2.6 | Editor Functions
2.7 | WXME Decoding

▼ | 2.3 | Drawing Classes

2.3.1 | bitmap%
2.3.2 | bitmap-dc%
2.3.3 | brush%
2.3.4 | brush-list%
2.3.5 | color%
2.3.6 | color-database<%>
2.3.7 | dc<%>
2.3.8 | dc-path%
2.3.9 | font%
2.3.10 | font-list%
2.3.11 | font-name-directory<%>
2.3.12 | gl-config%
2.3.13 | gl-context<%>
2.3.14 | pen%
2.3.15 | pen-list%
2.3.16 | point%
2.3.17 | post-script-dc%
2.3.18 | printer-dc%
2.3.19 | ps-setup%
2.3.20 | region%

On this page:

find-family-default-font-id
find-or-create-font-id
get-face-name
get-family
get-font-id
get-post-script-name
get-screen-name
set-post-script-name
set-screen-name

top← prev up next →

font-name-directory<%> : interface?

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 optional face string. Font IDs are 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 Configuration 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 X, 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\n Serif" maps to the font that is typically used for button labels. Under X, a face name has a more complex interpretation:

- If the string begins with a space, then the remainder of the string is interpreted as a fontconfig/Xft font name, but only if fontconfig/Xft support is enabled at compile time (which is the default when available), and only if the RENDER extension is available at run time. Multiple fontconfig/Xft font names can appear after the initial space, separated by commas; the first available font is used to draw text, and later fonts are substituted for missing characters in earlier fonts.

- If the string begins with +, then the remainder of the string is interpreted as an X font name. These names are usually long, such as +-b&h-lucidatypewriter-medium-r-normal-sans-24-240-75-75-m-140-iso8859-1. As usual for X font names, asterisks may appear in the string as wildcards. Furthermore, the size of the font can be parameterized by using %d in the place of a specific point size; if an asterisk appears in place of the pixel size, the asterisk and %d are swapped when the font size is specified in pixels (otherwise the size is always interpreted as points). For rotated text, %d will be replaced by a transformation matrix.

- A string of the form -‹provider›-‹font› is equivalent to +-‹provider›-‹font›-‹weight›-‹style›-normal-*-*-%d-*-*-*-*-*-*, where ‹weight› is either medium, light, or bold (depending on the requested weight mapping) and ‹style› is either r, i, or i (depending on the requested style mapping).

- A string of the form -‹font› is equivalent to -*-‹font›.

- A string of any other format is interpreted as an X font name, optionally parameterized with %d.

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

( send a-font-name-directory find-family-default-font-id family)
→ exact-integer?

family

:

( one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)

Gets the font ID representing the default font for a family. See font% for information about font families.

( send a-font-name-directory find-or-create-font-id |  | name |
|  | family) |

→ exact-integer?
name : string?

family

:

( one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)

Gets the face name for a font ID, initializing the mapping for the face name if necessary.

Font ID are useful only as mapping indices for the-font-name-directory.

( send a-font-name-directory get-face-name font-id)
→ ( or/c string? false/c)
font-id : exact-integer?

Gets the face name for a font ID. If the font ID corresponds to the default font for a particular family, #f is returned.

( send a-font-name-directory get-family font-id)

→

( one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)

font-id : exact-integer?

Gets the family for a font ID. See font% for information about font families.

( send a-font-name-directory get-font-id |  | name |
|  | family) |

→ exact-integer?
name : string?

family

:

( one-of/c 'default 'decorative 'roman 'script
'swiss 'modern 'symbol 'system)

Gets the font ID for a face name paired with a default family. If the mapping for the given pair is not already initialized, 0 is returned. See also find-or-create-font-id.

Font ID are useful only as mapping indices for the-font-name-directory.

( send a-font-name-directory get-post-script-name |  | font-id |
|  | weight |
|  | style) |

→ ( or/c string? false/c)
font-id : exact-integer?
weight : ( one-of/c 'normal 'bold 'light)
style : ( one-of/c 'normal 'italic 'slant)

Gets a PostScript font name for a font ID, weight, and style combination. The PostScript font name is used both for the font name in PostScript output (sans character set) and as the Adobe Font Metrics file name; see also PostScript Fonts.

See font% for information about weight and style.

( send a-font-name-directory get-screen-name |  | font-id |
|  | weight |
|  | style) |

→ ( or/c string? false/c)
font-id : exact-integer?
weight : ( one-of/c 'normal 'bold 'light)
style : ( one-of/c 'normal 'italic 'slant)

Gets a platform-dependent screen font name (used for drawing to a canvas’s dc<%>, a bitmap-dc%, or a printer-dc%) for a font ID, weight, and style combination.

See font% for information about weight and style.

( send a-font-name-directory set-post-script-name |  | font-id |
|  | weight |
|  | style |
|  | name) |

→ void?
font-id : exact-integer?
weight : ( one-of/c 'normal 'bold 'light)
style : ( one-of/c 'normal 'italic 'slant)
name : string?

Sets a PostScript font name for a font ID, weight, and style combination. See also get-post-script-name.

See font% for information about weight and style.

( send a-font-name-directory set-screen-name |  | font-id |  |  |  |
|  | weight |  |  |  |
|  | style |  |  |  |
|  | name) |  | → |  | void?

font-id : exact-integer?
weight : ( one-of/c 'normal 'bold 'light)
style : ( one-of/c 'normal 'italic 'slant)
name : string?

Sets a platform-dependent screen font name (used for drawing to a canvas’s dc<%>, a bitmap-dc%, or a printer-dc%) for a font ID, weight, and style combination.

Under X, if the screen name contains %d, it is replaced by the size of the font (point size times 10) to obtain the full screen font name.

See font% for information about weight and style.
top← prev up next →