See what's going on with flipcode!




This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.

 

  Anti-Aliased GDI Text
  Submitted by



Here is a little trick to show antialiased text with GDI functions.

The code:

// use LOGFONT structure to add a font.
LOGFONT lfont;
lfont.lfHeight = 55;
lfont.lfWidth = 0;
lfont.lfEscapement = 0;
lfont.lfOrientation = 0;
lfont.lfWeight = FW_BOLD;
lfont.lfItalic = 0;
lfont.lfUnderline = 0;
lfont.lfStrikeOut = 0;
lfont.lfCharSet = ANSI_CHARSET;
lfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
lfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
// lfQuality Specifies the output quality. Use ANTIALIASED_QUALITY!
lfont.lfQuality = ANTIALIASED_QUALITY;
lfont.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
lstrcpy(lfont.lfFaceName,"Arial");
HFONT oldfont, hfont_antialias = CreateFontIndirect(&lfont);
oldfont = (HFONT)SelectObject(hdc, hfont_antialias);
TextOut(hdc, 100, 100, "This is an antialiased text", 27);
//.... and so on .... 

I thought I have to code my own antialiasing engine but somtimes it's more simply than one thinks.

CU.
Thomas Gorski


The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.

 

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.