Alpha Fonts
Alpha
Version:9.2.3 - "Suhail"
Last update:2021-05-21 14:43:30





This help file explains how fonts are specified in AlphaTcl and describes some core commands which provide information about fonts or let you define a font specification.

Font specification

Syntax of -font option

Many Alpha commands accept a -font option. The value of this option is a Tcl dictionary containing some of the following keys:
name
the value is the name of a font. Use the [getFontList] command to get a list of the available fonts.
size
the value is a floating number or an integer specifying the size of the font.
meta
the value is a metafont name. This designates a font which is system dependent.
The name and meta keys in the font dictionary are mutually exclusive.
If the size key is not specified, the default value is 10 points for named fonts or a default size provided by the system for metafonts.
The possible metafont names used for the meta entry in the dictionary are:
control
the font used for the content of controls.
label
the Aqua font used for standard interface labels.
menuBar
the font used for menu bar items.
menu
the font used for menu items.
message
the font used for standard interface items, such as button labels, menu items, and so on.
palette
the font used for palette window title bars.
system
the Aqua system font used for standard interface items, such as button labels, menu items, and so on.
systemBold
the Aqua system font used for standard interface items that are rendered in boldface type.
titleBar
the font used for window title bars.
toolTips
the font used for tool tips labels.
userFixed
the font used by default for documents and other text under the user's control (that is, text whose font the user can normally change), when that font should be fixed-pitch.
user
the font used by default for documents and other text under the user's control (that is, text whose font the user can normally change).
These metafont names are case insensitive.

Examples

Here are some examples of specification of a -font option which could be used in commands such as [getTextDimensions], [abbreviateText] or [view configure]:
    -font [list name "Monaco" size 10]
    -font [list name "Menlo-Italic" size 11.0]
    -font [list name "Arial-BoldItalicMT" size 11.0]
    -font [list meta system size 14]
    -font [list meta label]
In the last example, the size of the metafont is not specified: in that case, the system decides on a default value which may vary depending on the version of the system and the machine.

Font preferences

Older versions of AlphaTcl had separate preferences for font names and for font sizes. This is no longer the case. There is a new preference type called font whose value is specified by a font dictionary.
In particular, the Default Font preference (in the Appearance Preferences panel), used when a new document window is opened, adopts the new syntax. Its value is currently defined as:
    name Menlo-Regular size 11
From the user's point of view, the selection of a font is completely transparent: a dialog window asks to select a font (and possibly a size and a style) from the Fonts Panel and, once the user presses OK, takes care of retrieving the selected value in the expected format.

The [getFontList] command

getFontList ?-mask num?
If no argument is specified, return the list of available fixed-size fonts. If the -mask option is specified, the command returns all the fonts corresponding to the specified value (not only fixed-size fonts). The value of this option is an additive value containing some of the following flags:
Italic1
Bold2
Unbold4
Narrow16
Expanded32
Condensed64
Small Caps128
Poster256
Compressed512
Fixed Size1024
If the -mask option is explicitely set to 0 (rather than being unspecified), the command returns the list of all available font families. The following pairs of flags are mutually exclusive: Condensed and Expanded, Bold and Unbold.

The [getFontInfo] command

getFontInfo font ?option?
If an option is specified, return the value for this option. Otherwise return a dictionary of key/value pairs for all possible options. The currently available options are:
angleamount that the font is slanted in degrees counterclockwise from the vertical
ascendertop y-coordinate, offset from the baseline, of the longest ascender
boundRectunion of the bounding rectangles of every glyph in the font
capHeightheight of a capital letter above the baseline
countnumber of glyphs in the font
descenderbottom y-coordinate, offset from the baseline, of the longest descender
displayNamename, including family and face, localized for the user's language
familyfamily name
fixedindicates if the font has fixed size
leadingleading of the font
maxAdvancemaximum advancement
namename of the font
renderingrendering mode
sizepoint size of the font
xHeightdistance between the baseline and the mean line of lower-case letters
The rendering mode returned by the rendering option can have one of the following values:
0Default
1Antialiased
2Integer Advancements
3Antialiased Integer Advancements

The [showFontPanel] command

showFontPanel
Display the font selection panel. Selecting a font or size from this panel automatically effects the current document window.

The [getFont] command

getFont ?-prompt str? ?-sample str? ?-title str? ?-defaut font?
Prompt the user to select a font and a size. The command also displays the system font panel: fonts are selected in the font panel and echoed in the dialog. Press the OK button to end up the selection and validate the choice. The returned value is a font specification (i-e a Tcl dictionary with name and size keys), or an error if the Cancel button was pressed.
The -prompt option specifies a text to display at the top of the dialog. If it is not specified, a default string is used.
The -title option specifies a title for the dialog. By default, there is no title.
The -sample option specifies a string to use as sample text. This sample text is displayed using the currently selected font: each time the user changes the font in the font panel, the sample field is updated.
The -default option specifies a default font to display as a suggestion in the dialog. If it is not specified, the default font preference is used.