//先來個例子: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;
//因為 Canvas 的 Font 屬性就是 TFONT 類的一個實例, 所以上面的程序可以簡化為:procedure TForm1.FormPaint(Sender: TObject);
{OrIEntation: 旋轉角度, 單位是 1/10 度, 舉個例子:}
const
S = '萬一的 Delphi 博客';
begin
Canvas.Font.Name := '微軟雅黑';
Canvas.Font.Style := [fsBold, fsItalic];
Canvas.Font.Color := clRed;
Canvas.Font.Height := 72;
Canvas.TextOut(10, 10, S);
end;
//TFont 類的常用屬性:
{Name: 字體名稱}
{Color: 顏色}
{Size、Height: 字號與字體高度, 都可以設定字體大小}
{Style: 字體樣式; 是個集合值, 是下面可選值或它們的組合:}
fsBold
fsItalic
fsUnderline
fsStrikeOut
{Pitch: 是字間距相關的, 有三個枚舉值可選(不過我沒測試出效果):}
fpDefault
fpVariable
fpFixed
{Charset: 字符集, 是個整數, 可能的值有:}
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;
//代碼:const
//效果圖:
S = '萬一的 Delphi 博客';
begin
Canvas.Font.Style := [fsBold];
Canvas.Font.Color := clRed;
Canvas.Font.Height := 32;
Canvas.Font.OrIEntation := 450;
Canvas.TextOut(0, ClIEntHeight-20, S);
end;