var I: Integer; begin I := Ord(Form1.Font.Pitch); Form1.Font.Pitch := TFontPitch(I); end;
对于FontStyle就稍微复杂点 var I: Integer; begin // Save font style I := 0; if fsBold in Form1.Font.Style then I := I or 1; if fsItalic in Form1.Font.Style then I := I or 2; if fsUnderline in Form1.Font.Style then I := I or 4; if fsStrikeOut in Form1.Font.Style then I := I or 8;
// Load font style if I and 1 = 1 then Form1.Font.Style := Form1.Font.Style + [fsBold] else Form1.Font.Style := Form1.Font.Style - [fsBold]; if I and 2 = 2 then Form1.Font.Style := Form1.Font.Style + [fsItalic] else Form1.Font.Style := Form1.Font.Style - [fsItalic]; if I and 4 = 4 then Form1.Font.Style := Form1.Font.Style + [fsUnderline] else Form1.Font.Style := Form1.Font.Style - [fsUnderline]; if I and 8 = 8 then Form1.Font.Style := Form1.Font.Style + [fsStrikeOut] else Form1.Font.Style := Form1.Font.Style - [fsStrikeOut]; end;
----------------------------------------------