PRB: Fonts Not Drawn Antialiased on Device Context for DirectDraw Surface (305290)



The information in this article applies to:

  • Microsoft DirectX Software Development Kit 7.0, when used with:
    • the operating system: Microsoft Windows 95
    • the operating system: Microsoft Windows 98
    • the operating system: Microsoft Windows 98 Second Edition
    • the operating system: Microsoft Windows Millennium Edition

This article was previously published under Q305290

SYMPTOMS

On the Windows 95, Windows 98, and Windows Millennium Edition platforms, fonts selected to be drawn antialiased on a DirectDraw surface device context (DC) are not drawn antialiased.

CAUSE

There is a problem in the operating system that turns off antialiasing if a font is first selected into a non-display DC.

RESOLUTION

The first time you select a font, select in into a display DC.

MORE INFORMATION

A font that is capable of being displayed antialiased will be drawn antialiased when the ANTIALIASED_QUALITY flag is used in the call to CreateFont. A handle to a DC returned from IDirectDrawSurface7::GetDC() will not draw the font antialiased as it would on a normal display DC. You can create a temporary display DC, select the font into it, and then select the font into the DirectDraw DC to work around the problem, as demonstrated below. The same workaround applies to DIB sections.
// hdcTTSurface is a DC to your target DirectDraw surface. It is
//   obtained by calling IDirectDrawSurface7::GetDC
// hAAfont is a logical font handle to the font you have selected 
//   capable of being drawn antialiased.

HDC hdcScreen;
HFONT hOldScreenFont, hOldSurfaceFont;

hdcScreen = GetDC(0);
hOldScreenFont = SelectObject(hdcScreen , hAAfont);
SelectObject(hdcScreen, hOldScreenFont);
hOldSurfaceFont = (HFONT)SelectObject(hdcDDSurface, hAAfont);

//Now, you can draw the font antialiased.
				

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

306198 PRB: Cannot Draw Anti-Aliased Text on a Windows DIB Section


Modification Type:MinorLast Reviewed:5/3/2006
Keywords:kbDSWGDI2003Swept kbDirectDraw kbFont kbGDI kbprb KB305290