12 font-name-directory<%>

▼ |  | The Racket Drawing Toolkit

1 | Overview
2 | bitmap%
3 | bitmap-dc%
4 | brush%
5 | brush-list%
6 | color%
7 | color-database<%>
8 | dc<%>
9 | dc-path%
10 | font%
11 | font-list%
12 | font-name-directory<%>
13 | gl-config%
14 | gl-context<%>
15 | linear-gradient%
16 | pdf-dc%
17 | pen%
18 | pen-list%
19 | point%
20 | post-script-dc%
21 | ps-setup%
22 | radial-gradient%
23 | record-dc%
24 | region%
25 | svg-dc%
26 | Drawing Functions
27 | Drawing Contracts
28 | Signature and Unit
29 | Unsafe Libraries
30 | Drawing Conveniences
31 | Platform Dependencies
| Bibliography
| Index

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 contents ← prev up next →

interface font-name-directory<%> : interface?

There is one font-name-directory<%> object: the-font-name-directory. It implements a mapping from font specifications (face, family, style, and weight) to information for rendering text on a specific device. 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. For a family with a face string, the-font-name-directory interprets the string (in a platform-specific way) to generate a mapping for drawing (to a canvas’s dc<%>, a bitmap-dc%, or a printer-dc%).

Currently, on all platforms, a face string is interpreted as a Pango font description when it contains a comma, otherwise it is treated as a family name. A face can thus be just a family name such as "Helvetica", a family followed by a comma and font modifiers as in "Helvetica, Bold", or a sequence of comma-separated familie names followed by space-separated font options as an "Helvetica, Arial, bold italic". Any size in a font description is overridden by a given font%’s size. Any (slant) style or weight options in a font description are overridden by a non-'normal value for a given font%’s style or weight, respectively.

> method (send a-font-name-directory find-family-default-font-id family)
> → exact-integer?
> | family |  | : |  |
> (or/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.

> > method
> > (send a-font-name-directory find-or-create-font-id |  | name |
> > |  | family) |
> → exact-integer?
> name : string?
> | family |  | : |  |
> (or/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.

> method (send a-font-name-directory get-face-name font-id)
> → (or/c string? #f)
> 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.

> method (send a-font-name-directory get-family font-id)
> | → |  |
> (or/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.

> > method
> > (send a-font-name-directory get-font-id |  | name |
> > |  | family) |
> → exact-integer?
> name : string?
> | family |  | : |  |
> (or/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.

> > method
> > (send a-font-name-directory get-post-script-name |  | font-id |
> > |  | weight |
> > |  | style) |
> → (or/c string? #f)
> font-id : exact-integer?
> weight : (or/c 'normal 'bold 'light)
> style : (or/c 'normal 'italic 'slant)

Gets a PostScript font description for a font ID, weight, and style combination.

See font% for information about weight and style.

> > method
> > (send a-font-name-directory get-screen-name |  | font-id |
> > |  | weight |
> > |  | style) |
> → (or/c string? #f)
> font-id : exact-integer?
> weight : (or/c 'normal 'bold 'light)
> style : (or/c 'normal 'italic 'slant)

Gets a platform-dependent screen font description (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.

> > method
> > (send a-font-name-directory set-post-script-name |  | font-id |
> > |  | weight |
> > |  | style |
> > |  | name) |
> → void?
> font-id : exact-integer?
> weight : (or/c 'normal 'bold 'light)
> style : (or/c 'normal 'italic 'slant)
> name : string?

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

See font% for information about weight and style.

> > method
> > (send a-font-name-directory set-screen-name |  | font-id |  |  |  |
> > |  | weight |  |  |  |
> > |  | style |  |  |  |
> > |  | name) |  | → |  | void?
> font-id : exact-integer?
> weight : (or/c 'normal 'bold 'light)
> style : (or/c 'normal 'italic 'slant)
> name : string?

Sets a platform-dependent screen font description (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.
top contents ← prev up next →