DaniWeb IT Discussion Community

Code Snippets (http://www.daniweb.com/code/)
-   delphi (http://www.daniweb.com/code/delphi.html)
-   -   Disable font smoothing (Anti-aliased font) (http://www.daniweb.com/code/snippet472.html)

Lord Soth delphi syntax
Mar 18th, 2006
This code disables font smoothing for a TLabel component. Can easily be converted for other VCL controls.

Loren Soth

  1. procedure TForm1.DisableFontSmoothing(LabelName: TLabel);
  2. var
  3. tagLOGFONT: TLogFont;
  4. begin
  5. GetObject(LabelName.Font.Handle, SizeOf(TLogFont), @tagLOGFONT);
  6. tagLOGFONT.lfQuality := NONANTIALIASED_QUALITY;
  7. LabelName.Font.Handle := CreateFontIndirect(tagLOGFONT);
  8. end;
  9.  
  10. //Example Use for Label2
  11. procedure TForm1.Button1Click(Sender: TObject);
  12. begin
  13. DisableFontSmoothing(Label2);
  14. end;