The simplest use of these classes is as follows:
::tycho::queryfont Times 12 Italic
9x15
and 10x20
, for
example, are particularly nice screen fonts -- the font manager
provides these as a pseudo font Screen
. When the user selects a
font, a sample is displayed.
The arguments passed to this procedure represent the initial font
to be displayed, as its family, size, and style. Any number may be
supplied (provided they remain in the right order). If none are
supplied, the font default to
Helvetica 12 Roman
.
The style can be one of Roman
, Italic
,
Bold
, or Bold Italic
-- if omitted, it
defaults to Roman
. Font family names and styles are all
case-insensitive.
OK
, or the name of the initial font if the used presses
Cancel
. This can be used to set fonts in any Tycho text
widget. For example, the following code will query the
user for a font selection:
::tycho::queryfont Lucida 14 BoldItalic
The FontDialog class returns only a symbolic representation of the
font. To convert this into a system-dependent font, use the
::tycho::font
procedure. For example:
set font [::tycho::queryfont Screen 14]
eval ::tycho::font $font
Screen
font in an italic style: you
will get a courier
font instead. The ::tycho::font
procedure will always return a valid system font, even if it cannot
find a reasonable one: as a last resort, it will return the font
fixed
.
The font manager provides procedures that give applications more
detailed control over fonts. Firstly, ::tycho::font
can
"shift" up or down by some number of sizes:
::tycho::font Screen 12 roman -2
::tycho::FontManager::size
:
::tycho::FontManager::size 11 +1
serif
, sans-serif
, and constant-width
.
To find out the families in a particular type, use
::tycho::FontManager::family
:
::tycho::FontManager::family serif
::tycho::queryfont
and ::tycho::font
, and the font manager will choose
a font of the given type. Unless your installation of
Tycho has changed the font manager settings, this window will
display the system-dependent name for 14-point Courier:
::tycho::font constant-width 14
::tycho::FontManager::family
again:
::tycho::FontManager::family serif Rockwell times
Family
menu.
FontManager class documentation
FontDialog class documentation
Tycho Home Page