Microsoft KB Archive/305290

= PRB: Fonts Not Drawn Antialiased on Device Context for DirectDraw Surface =

Article ID: 305290

Article Last Modified on 5/3/2006

-

APPLIES TO

 Microsoft DirectX 7.0, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows 98 Second Edition

 Microsoft Windows Millennium Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q305290

<div class="symptoms_section">

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.

<div class="cause_section">

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

<div class="resolution_section">

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

<div class="moreinformation_section">

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.

<div class="references_section">