Let's start with an example:procedure TForm1.FormPaint(Sender: TObject);
const
S = '万一的 Delphi 博客';
var
font: TFont;
begin
font := TFont.Create;
font.Name := '微软雅黑';
font.Style := [fsBold, fsItalic];
font.Color := clRed;
font.Height := 72;
Canvas.Font := font;
Canvas.TextOut(10, 10, S);
font.Free;
end;
Effect Chart:
Because the Font property of the Canvas is an instance of the TFONT class, the above program can be simplified to:Procedure Tform1.formpaint (Sender:tobject);
Const
S = ' In case of Delphi blog ';
Begin
Canvas.Font.Name: = ' Microsoft Ya-hei ';
Canvas.Font.Style: = [Fsbold, fsitalic];
Canvas.Font.Color: = clred;
Canvas.Font.Height: = 72;
Canvas.textout (A, S);
End
Common properties for the TFont class:
{Name: Font name}
{color: Colors}
{size, Height: Font size and font height, you can set the font sizes}
{style: font style; is a collection value, which is the following optional value or a combination of them:}
Fsbold
Fsitalic
Fsunderline
Fsstrikeout
{Pitch: Is word spacing related, there are three enumerated values optional (but I did not test the effect):}
Fpdefault
Fpvariable
Fpfixed
{Charset: Character set, is an integer, the possible values are:}
Ansi_charset = 0;
Default_charset = 1;
Symbol_charset = 2;
Shiftjis_charset = 128;
Hangeul_charset = 129;
Gb2312_charset = 134;
Chinesebig5_charset = 136;
Oem_charset = 255;
Johab_charset = 130;
Hebrew_charset = 177;
Arabic_charset = 178;
Greek_charset = 161;
Turkish_charset = 162;
Vietnamese_charset = 163;
Thai_charset = 222;
Easteurope_charset = 238;
Russian_charset = 204;