|Allegro CL version 8.2|
Unrevised from 8.1 to 8.2.
Arguments: family face size &optional style angle
Both make-font and make-font-ex return a font object with the given components. Family and face specify the family and face of the font. The two functions differ only in the interpretation of the size of a font. See below under the heading Font sizes for information on size and on the size-is-cell-height-p argument to make-font-ex.
Other than size, fonts are canonicalized so that those with the same components are eq.
The family argument is a general specification for the style of the font, and is used only if the requested face is not installed in the operating system. (On GTK, the family is never used.) It may be one of the symbols
:swiss: variable-width fonts without serifs
:roman: variable-width fonts with serifs
:modern: fixed-width fonts, with or without serifs
:script: fonts designed to look like cursive handwriting
:decorative: novelty fonts, such as Old English
nil if there is no preference.
The face argument specifies the unique name of an individual typeface that may be installed in the operating system. The name may be a string or symbol, though a string is now preferred and the symbol option is provided mainly for backward compatibility. The string is not case sensitive. If the requested face is not installed, then a default face for the requested family is used.
A list of all currently installed font face names is returned by the
form (see font-faces, screen, and
(font-faces (screen *system*))
If the exact font that was requested is not available, the operating system substitutes an approximate font. Once the returned font has been assigned to a stream by calling (setf font), exact-font may be called on the font to return a font object whose family, face, size, and other attributes reflect the actual font being used.
Platform note: Font face names are different on different platforms. If the following common Microsoft Windows font face names are specified on the GTK platform, an attempt will be made to map to a comparable GTK font automatically: Arial, Arial Black, Times New Roman, MS Serif, MS Sans Serif, Courier New, System, and Fixedsys. (No similar attempt is made on Windows to map common GTK font faces to Windows font faces.) If you need to hardcode other font names, you may need to conditionalize the code with #+mswindows and #+gtk.
The size should be a positive real number that indicates the height of the font in pixels. On Windows the value is typically an integer, though non-integer real numbers work as well. On GTK, fonts seem to look better when the point size is an integer, though this argument is measured in pixels rather than points. So on GTK it may be a good idea to pass a desired integer point size to the function points-to-pixels and then pass the returned real pixel size to make-font-ex/make-font. See the information under the heading Font Sizes below for more information.
The style may be either a list of any of
the style keywords shown below, or a single number derived by adding
the associated weights, or
nil to indicate
none of the optional styles. The keywords and their integer
:boldstyle has weight 1.
:italicstyle has weight 2.
:underlinestyle has weight 4.
:condensedstyle has weight 32.
The angle argument specifies the angle at which
to draw all strings that are drawn in this font. If
nil or unspecified, then text is drawn at the usual
horizontal angle. Otherwise angle should be an integer indicating
degrees counterclockwise to rotate text from the usual horizontal
angle. (So 90 for vertical, first letter lowest, 180 for upside down,
and 270 for vertical, first letter highest. These are examples; angles
which are not multiples of 90 are also supported.) The text will be
rotated about the upper-left corner of the string. draw-string-in-box is therefore not suitable for
drawing text at non-zero angles, and Common Lisp stream output
functions such as format and
princ should be used instead;
these functions which will draw from the current-position of the stream at the angle of
the font. font-angle applied
to a font returns the angle.
See also ask-user-for-font and vary-font.
You may notice that the size specified to a Common Font dialog
is different from the size specified to make-font to get the same
result. For example, if you call ask-user-for-font (which displays a
Common Font dialog), and ask for Times regular, size 11, you get the
same font as returned by
(make-font :roman :times
Why the difference? There are two causes: first, Allegro CL measures font sizes in pixels while the Common Dialog measures in points; (see pixels-to-points and points-to-pixels); and second, the size shown in the Common Dialog indicates the "character height" (the height of the pixels that are actually drawn for a character) while the size used by make-font indicated the "cell height" (the character height plus an unpredictable number of blank pixel rows of "leading").
The function make-font-ex harmonizes Allegro CL with the Windows Common Font dialog. It uses character height rather than cell height (unless the size-is-cell-height-p optional argument is specified true, which forces the older cell-height interpretation and makes make-font-ex equivalent to make-font). The units are still pixels, though, rather than points.
Font objects are printed
#.([make-font-ex-form]). Every font
created by make-font prints as
Fonts made by make-font-ex print as
#.([make-font-form]) depending on which
definition of size is used (controlled by the
size-is-cell-height-p optional argument).
A font returned by a Common Font dialog prints as a make-font-ex form. Fonts made or created from other existing fonts will use the format of the starting font.
See also Text and Fonts in cg-drawing.htm.
On X platforms, using many different fonts (including different sizes and styles of the same face) may slow down redisplay greatly if the fonts do not all fit simultaneously into the X server's cache for font data.
Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
|Allegro CL version 8.2|
Unrevised from 8.1 to 8.2.