Programmer Reference : Common Graphics : Using fonts : Assigning fonts for use in drawing operations
Assigning fonts for use in drawing operations
Before a font can be used in a drawing operation, it must be assigned to a graphics context. All text drawing operations use the font in the graphics context. A CgFont is assigned to the graphics context using the setFont: method.
| font |
font := CgDisplay default
loadFont: '-*-helvetica-bold-r-normal-*-*-240-*-*-*-*-*-*'.
CgGC default
setFont: font.
The following example shows assigning a CgFontStruct for use in a graphics context:
| fontStruct |
fontStruct := CgDisplay default
loadQueryFont: '-*-helvetica-bold-r-normal-*-*-240-*-*-*-*-*-*'.
CgGC default
"The setFont: method expects to be passed a CgFont"
setFont: fontStruct font.
Last modified date: 01/29/2015