# Blurry ID3DXFont in windowed mode

## Recommended Posts

FoxHunter2    157
Hi! I'm using ID3DXFont in my DirectX9 application to output some statistics on the screen. In fullscreenmode the font looks fine and sharp, but in windowed mode the font look very ugly and blurry, hard to read. Anyone experienced this? If it helps, here's the code:
HDC hDC = GetDC(NULL);

LOGFONT fStatsFont;
ZeroMemory(&fStatsFont, sizeof(LOGFONT));
fStatsFont.lfHeight = -MulDiv(11, GetDeviceCaps(hDC, LOGPIXELSY), 72);
fStatsFont.lfWidth	= 0;
fStatsFont.lfOrientation = 0;
fStatsFont.lfEscapement = 0;
fStatsFont.lfWeight = FW_NORMAL;
fStatsFont.lfItalic = FALSE;
fStatsFont.lfUnderline = FALSE;
fStatsFont.lfStrikeOut = FALSE;
fStatsFont.lfCharSet = DEFAULT_CHARSET;
fStatsFont.lfOutPrecision = OUT_TT_PRECIS;
fStatsFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
fStatsFont.lfQuality = DEFAULT_QUALITY;
fStatsFont.lfPitchAndFamily = DEFAULT_PITCH;
strcpy(fStatsFont.lfFaceName, "Arial");

ReleaseDC(NULL, hDC);

hRes = D3DXCreateFontIndirect(pD3DDevice, &fStatsFont, &pD3DStatsFont);
if(FAILED(hRes))
{
Error(hRes, "D3DXCreateFontIndirect() failed!");
return false;
}
regards

##### Share on other sites
Supernat02    604
Do you have filtering enabled? Does the font take up exactly the same space in windowed mode as it does in full screen? If not, then it sounds like you might be setting the backbuffer width and height to something other than the window width and height when it is windowed. That's the only thing I could think of...

Chris

##### Share on other sites
Quote:
 Original post by Supernat02Do you have filtering enabled? Does the font take up exactly the same space in windowed mode as it does in full screen? If not, then it sounds like you might be setting the backbuffer width and height to something other than the window width and height when it is windowed. That's the only thing I could think of...Chris

I agree with Chris. It's not a problem with fonts, but with scaling sprites.

##### Share on other sites
FoxHunter2    157
Thanks so far, do you need any more information to track down my problem?

The backbuffer is set like this:
d3dpp.Windowed = TRUE;d3dpp.BackBufferWidth	= pSettings->Window_WindowedWidth();d3dpp.BackBufferHeight = pSettings->Window_WindowedHeight();

So the backbuffer and the window are of the same size.

There's no filtering used I'm aware of, how do I turn on filtering?
And what do you mean by "Does the font take up exactly the same space in windowed mode as it does in full screen?"

##### Share on other sites
xyzzy00    307
make sure that your backbuffer's width and height are the size of the client area of your window, and not the size of the whole window including borders, etc..

xyzzy

##### Share on other sites
Trip99    577
Yes that has caught me out before now. You can use GetViewport to find out what it is actually set to.

##### Share on other sites
FoxHunter2    157
Thanks a lot, that did the trick.

However, in Fullscreen mode the font is bigger than in windowed mode. Is this the correct behavior? I thought 14pt should be 14pt, or am I missing something?

##### Share on other sites
DrunkenHyena    805
It should be the same size in relation to the size of the render area. If you're comparing a 640x480 fullscreen vs. 640x480 window on a 1024x768 Desktop, then the fullscreen text will appear much bigger though they take up the same number of pixels.

##### Share on other sites
rKallmeyer    396
(chuckle) I was getting the same problem when I switched from fullscreen to windowed and yep, GetViewport fixed it, thanks aswell.

##### Share on other sites
FoxHunter2    157
thanks for the explanation, Ken.

by the way, just in this moment I'm reading your tutorials on DrunkenHyena.com. Great work, keep it up!