Next Prev Up Top Contents Index

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 runtime into the font represented by the specified style.

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

Arguments: display-device device-font-name

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.

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))


CommonLisp Interface Manager 2.0 User's Guide - 8 Aug 2003

Next Prev Up Top Contents Index