font
Create and inspect fonts.
(font option ?arg arg ...?)
The font procedure provides several facilities for dealing with
fonts, such as defining named fonts and inspecting the actual attributes of
a font. The procedure has several different forms, determined by the
first argument. The following forms are currently supported:
- (font 'actual font {?B:displayof} {IwindowR?} {?IoptionR?)}
-
- (font 'configure fontname ?option? ?value option value ...?)
-
- (font 'create ?fontname? ?option value ...?)
-
- (font 'delete fontname ?fontname ...?)
-
- (font 'families)
-
- (font 'families {B:displayof} {IwindowR?)}
-
- (font 'measure font {?B:displayof} {IwindowR?} {ItextR)}
-
- (font 'metrics font {?B:displayof} {IwindowR?} {?IoptionR?)}
-
- (font 'names)
-
The return value is a list of all the named fonts that are currently defined.
The following formats are accepted as a font description anywhere
font is specified as an argument above; these same forms are also
permitted when specifying the :font option for widgets.
- {[1]} fontname
-
- {[2]} systemfont
-
- {[3]} family ?size? ?style? ?style ...?
-
normal bold roman italic
underline overstrike
- {[4]} X-font names (XLFD)
-
- {[5]} option value ?option value ...?
-
When font description font is used, the system attempts to parse the
description according to each of the above five rules, in the order specified.
Cases [1] and [2] must match the name of an existing named font or of a
system font. Cases [3], [4], and [5] are accepted on all
platforms and the closest available font will be used. In some situations
it may not be possible to find any close font (e.g., the font family was
a garbage value); in that case, some system-dependant default font is
chosen. If the font description does not match any of the above patterns,
an error is generated.
- :ascent
-
- :descent
-
- :linespace
-
- :fixed
-
The following options are supported on all platforms, and are used when
constructing a named font or when specifying a font using style [5] as
above:
- :family name
-
- :size size
-
Sizes should normally be specified in points so the application will remain
the same ruler size on the screen, even when changing screen resolutions or
moving scripts across platforms. However, specifying pixels is useful in
certain circumstances such as when a piece of text must line up with respect
to a fixed-size bitmap. The mapping between points and pixels is set when
the application starts, based on properties of the installed monitor, but it
can be overridden by calling (tk-state 'scaling).
- :weight weight
-
- :slant slant
-
The amount the characters in the font are slanted away from the
vertical. Valid values for slant are roman and italic.
A roman font is the normal, upright appearance of a font, while
an italic font is one that is tilted some number of degrees from upright.
The closest available slant to the one specified will be chosen.
The default slant is roman.
- :underline boolean
-
The value is a boolean flag that specifies whether characters in this
font should be underlined. The default value for underline is #f.
- :overstrike boolean
-
The value is a boolean flag that specifies whether a horizontal line should
be drawn through the middle of characters in this font. The default value
for overstrike is #f.
The following named system fonts are supported:
- X Windows:
-
All valid X font names, including those listed by xlsfonts(1), are available.
- MS Windows:
-
system ansi device
systemfixed ansifixed oemfixed
- Macintosh:
-
system application
Back to the STk main page