NONANTIALIASED_QUALITY
在结构中指定LOGFONT
应该关闭抗锯齿:
procedure SetFontQuality(Font: TFont; Quality: Byte);
var
LogFont: TLogFont;
begin
if GetObject(Font.Handle, SizeOf(TLogFont), @LogFont) = 0 then
RaiseLastOSError;
LogFont.lfQuality := Quality;
Font.Handle := CreateFontIndirect(LogFont);
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
const
FontQualities: array[Boolean] of Byte = (DEFAULT_QUALITY, NONANTIALIASED_QUALITY);
var
Canvas: TCanvas;
begin
Canvas := (Sender as TPaintBox).Canvas;
SetFontQuality(Canvas.Font, FontQualities[CheckBox1.Checked]);
Canvas.TextOut(12, 12, 'Hello, world!');
end;