Why are not all texts of my MFC applicatiopn displayed using ClearType?

1.3k Views Asked by At

I've got an MFC application that is built with VC6. When ClearType is enabled (Windows XP) some texts are rendered smoothly, i.e. with ClearType, and others are not.

Dialog texts don't seem to ever get rendered with ClearType. Some list controls, however, have it enabled completely, others only in their headers.

What could be the reason for this? Where should I look to find out why it works only in some places and doesn't in others?

Update
As requested, here is an enlarged screenshot. Obfuscated but the important parts should be visible.

  • In List 1 only the heading is smooth, the content is not.
  • In List 2 both, heading and list items are smooth.
  • The Dialog at the bottom is not using ClearType either.

screenshot of cleartype working sometimes and sometimes not

2

There are 2 best solutions below

2
On

Bitmap fonts will never use ClearType. Usually you won't use a bitmap font, but I believe the default selected into a DC is the System font, which is bitmap.

0
On

ClearType is a quality property for fonts. You should get the LOGFONT for your CFont and set the lfQuality property. Here's an example.

CFont *pFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));
LOGFONT logFont;
pFont->GetLogFont(&logFont);
logFont.lfQuality = CLEARTYPE_NATURAL_QUALITY;

CFont font2;
font2.CreateFontIndirect(&logFont);

Note: you can use either CLEARTYPE_QUALITY or CLEARTYPE_NATURAL_QUALITY, test both to see which looks best.