All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Chapter 4 Text Styles

NextPrevUpTopContentsIndex

4.5 Controlling Text Style Mappings

Text styles are mapped to fonts using the text-style-mapping function, which takes a port and a text style, and returns a font object. All ports implement methods for the following generic functions, for all classes of text style.

The objects used to represent a font mapping are unspecified and are likely to vary from port to port. For instance, a mapping might be some sort of font object on one type of port, or might simply be the name of a font on another. Part of initializing a port is to define the mappings between text styles and font names for the port's host window system.

text-style-mapping [Generic Function]

Arguments: port text-style

Summary: Returns the font mapping that will be used when rendering characters in the text style text-style on any medium on the port port . If there is no mapping associated with text-style on port , then some other object will be returned that corresponds to the "unmapped" text style.

(setf text-style-mapping) [Generic Function]

Arguments: mapping port text-style

Summary: Sets the text style mapping for port and text-style to mapping . port and text-style are as for text-style-mapping . mapping is either a font name or a list of the form ( :style family face size ); in the latter case, the given style is translated at run time into the font represented by the specified style.

make-device-font-text-style [Function]	

Arguments: port font-description &rest attributes

Summary: Returns a text style object that will be mapped directly to the specified device font when text is output to the display device with this style. Device font styles do not merge with any other kind of style. As the specified font is device-specific, the use of this function may result in non-portable applications.

port is the port that the font is going to be used on.

make-device-font-text-style first use font-description and attributes to construct a gp:font-description as follows:

If font-description is a gp:font-description object, it is used as is and attributes is ignored.

If font-description is a string, it should be a family name, and a gp:font-description is created by executing:

(apply 'gp:make-font-description
:family font-description
atributes )

If font-description is nil, a gp:font-description is created by executing:

(apply 'gp:make-font-description attributes)

make-device-font-text-style tries to find a device font that matches the gp:font-description . If it is successful, it returns a text-style that maps to this device font. If it is not successful, it return nil .

The gp:font-description objects are described in the CAPI User Guide and Reference Manual . See the section "Portable font descriptions" in the chapter "Drawing - Graphics Ports", and make-font-description in the GRAPHICS-PORTS Reference Entries chapter.

This code creates a device font text style and applies it to a string of characters.

(let ((my-device-font
(make-device-font-text-style
(port my-sheet)
(gp:make-font-description :family "courier"
:size 14
:weight :medium
:slant :italic))))
(draw-text* my-sheet "This appears in the specified device font."
10 10 :text-style my-device-font))


Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017

NextPrevUpTopContentsIndex