The normal screen, helvetica, roman and times font families available in the Unix/X11 version are available using the same names. The system will try to use an as close as possible equivalent Windows TrueType font for these.
The Windows `stock' fonts as available from the GetStockObject() API are available under the special `family' "win". They are in table 11
font(win, ansi_fixed) | Default ANSI encoded fixed font |
font(win, ansi_var) | Default ANSI encoded variable font |
font(win, device_default) | Default device font |
font(win, oem_fixed) | Computers `native' fixed font (PC) |
font(win, system) | Variable pitched system font |
font(win, system_fixed) | Fixed system font |
Table 11 : Windows font name mapping |
Note that these fonts do not have a specified point-size. Their
point-size depends on the Windows installation. The get-method <-
points
will return the <-
height of the font.
Other Windows fonts may be accessed using a similar method as in Unix/X11: provide a fourth argument describing the font using the hosts conventions. For the Win32 API, this is a textual description of the Windows API structure LOGFONT passed to CreateFontIndirect(). The description is a `:' (colon) separated list of attributes of the structure. The attributes need not be specified in the order of the structure-layout. Omited attributes are set to their default.
Attributes come in four types: numeric, boolean, enumerated and string. In general, an attribute is specified as:
<name>(<value>)<name> is matches case-insensitive against the name of the structure field without the leading `lf' string. For numeric types, the argument is interpreted as a decimal number (spaces are not allowed). For a boolean argument, the (value) part is omitted. By default the boolean attributes are FALSE. Including the attribute name in the specification sets the field to TRUE. Enumerated fields are specified using their symbolic name. Name-matching is case-insensitive. Common parts of the API identifier to make the symbol unique (for example _CHARSET in ANSI_CHARSET) are removed. String arguments simply take the value between the brackets. Spaces are included in the output, case is not changed and there is no escape for the closing-brace.
The default settings are in table 12, the attributes are in table 13.
charset | ansi |
height | <points> × font.scale |
weigth | bold if <style> is bold, normal otherwise |
italic | TRUE if <style> is italic or oblique |
pitch | fixed if <family> is screen |
family | swiss if <family> is helvetica, roman if <family> is times, modern if <family> is screen dontcare otherwise. |
face | <family> |
Table 12 : Windows font defaults |
height (int) | point-size of the requested font |
width (int) | average width of the characters |
escapement (int) | angle in 1/10 degrees of the baseline |
orientation (int) | angle for each character |
weigth (int) | 0..1000 scale for thickness |
italic | request italic look |
underline | underline all characters |
strikeout | use strikeout-fonts |
charset (enum) | character encoding
{ansi, oem, symbol } |
outprecision (enum) | accurate
aspects
{character, default, string, stroke } |
clipprecision (enum) | how the
characters clip
{character, default, stroke } |
quality (enum) | Quality of output
{default, draft, proof } |
pitch (enum) | Spacing attributes
{default, fixed, variable } |
family (enum) | Style of the
characters
{decorative, dontcare, modern, roman, script, swiss } |
face (string) | Use specific font database |
Table 13 : Windows font attributes |
The following example binds the Windows `WingDings' symbol-font:
1 ?- new(F, font(wingdings, roman, 20, 'charset(symbol)')).
The following example uses this font to create an image from such a character:
:- send(@display, font_alias, wingdings, font(wingdings, roman, 20, 'charset(symbol)')). wingding_image(Index, Image) :- new(Image, image(@nil, 32, 32)), new(T, text(string('%c', Index), center, wingdings)), send(T, center, point(16, 16)), send(Image, draw_in, T), send(T, done). test :- wingding_image(60, Floppy), send(label(test, Floppy), open).