All Manuals > CAPI User Guide and Reference Manual > 13 Drawing - Graphics Ports

13.9 Portable font descriptions

Portable font descriptions are designed to solve the following problems:

All the functions described below are exported from the gp package.

You can obtain the names of all the fonts which are available for a given pane by calling list-all-font-names, which returns a list of partially-specified font descriptions.

Portable font descriptions are used only for lookup of real fonts and for storing the parameters to specify when doing a font lookup operation. To draw text in a specified font using the Graphics Ports drawing functions, supply in the graphics state a font object as returned by find-matching-fonts and find-best-font.

13.9.1 Font attributes and font descriptions

Font attributes are properties of a font, which can be combined to uniquely specify a font on a given platform. There are some portable attributes which can be used on all platforms; other attributes are platform-specific and will be ignored or signal errors when used on the wrong platform.

Font descriptions are externalizable objects which contain a set of font attributes. When using a font description in a font lookup operation, missing attributes are treated as wildcards (as are those with value :wild) and invalid attributes signal errors. The result of a font lookup contains all the attributes needed to uniquely specify a font on that platform.

The :stock font attribute is special: it can be used to reliably look up a system font on all platforms.

Font descriptions can be manipulated using the functions merge-font-descriptions and augment-font-description.

These are the current set of portable font attributes and their portable types:

Set of portable font attributes
AttributePossible valuesComments

:family

string

Values are not portable.

:weight

(member :normal :bold)

:slant

(member :roman :italic)

:size

(or (eql :any) (integer 0 *))

:any means a scalable font

:stock

(member :system-font :system-fixed-font)

Stock fonts are guaranteed to exist.

:charset

keyword

13.9.2 Fonts

Fonts are the objects which are actually used in drawing operations. They are made by a font lookup operation on a pane, using a font description as a pattern.

Examples of font lookup operations are find-best-font and find-matching-fonts.

Once a font object is resolved you can read its properties such as height, width and average width. The functions get-font-height, get-font-width and get-font-average-width and so on need a pane that has been created. In general, you need to call these functions within interface-display, or a display-callback or possibly a create-callback. See the manual page for interface for more information about these initargs.

13.9.3 Font aliases

You can define font aliases, which map a keyword symbol to some font or font description, using define-font-alias. You can then use this the keyword as the font for CAPI panes.


CAPI User Guide and Reference Manual (Windows version) - 01 Dec 2021 19:33:53