The font used by certain widgets can be specified by the application. The following widgets allow their font to be changed: CwLabel, CwPushButton, CwToggleButton, CwCascadeButton, CwText, CwList, CwComboBox, and CwScale. The font is changed using the fontList: method. The font to use is specified by a CwFontList object.
To create a CwFontList, the fontStruct: class method of CwFontList is passed a CgFontStruct describing a Common Graphics font. A CgFontStruct can be loaded using the loadQueryFont: method of CgDisplay. For further details on fonts, consult "Using fonts".
The following code creates a multiline text widget and sets its font to the monospaced font named '8x13.'
| shell fontStruct fontList text | shell := CwTopLevelShell createApplicationShell: 'shell' argBlock: [:w | w title: 'Font List Example']. fontStruct := shell display loadQueryFont: '8x13'. fontList := CwFontList fontStruct: fontStruct.
text := shell createText: 'text' argBlock: [:w | w editMode: XmMULTILINEEDIT; fontList: fontList]. text setString: 'This text is displayed using the 8x13 font.'. text manageChild. shell realizeWidget