![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
You can change the font by sending a font:
message to the
graphics context, along with a suitable argument. In the following
definition, for example, the suitable argument is a constructed font that
you produce by sending the faceName:
message to a font instance
with an 'Algerian'
argument, and then sending the result the
bold:
message with a true
argument:
MeterGraphPane method definition instance drawMeter | thePen meterWidth xLft yBot oldFont | meterWidth := self width * 3 // 4. xLft := self width - meterWidth // 2. yBot := self height // 2. thePen := self pen. thePen lineFrom: xLft @ yBot to: (xLft + meterWidth) @ yBot. thePen lineFrom: (xLft + (meterWidth // 2)) @ yBot to: (xLft + (meterWidth // 2)) @ (yBot - 10). "Remember old values" oldFont := thePen font. "Set new values" thePen font: (Font new faceName: 'Algerian'; bold: true). thePen centerText: 'Untitled' at: ((self width) // 2) @ ((self height // 2) + (2 * thePen font height)). "Reset to old values" thePen font: oldFont.
The result is text printed in bold Algerian: