Jump to content
  • Advertisement
Sign in to follow this  
Roziks_World

Problem with Font size and Rendering Fonts

This topic is 3584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, i really still very new to this all. I am having a little problem rendering fonts. When the Font size is really big its all rendered fine and the Text is ok. But when i pick a smalle font size it gets all choppy and the text is not readable anymore. When i do it in Windowed mode and drag the window to a bigger size the Text gets more readable the bigger the window gets. Here is what i do: m_fontDesc.Height = 12; m_fontDesc.Width = 8; m_fontDesc.Weight = FW_NORMAL; m_fontDesc.MipLevels = 1; m_fontDesc.Italic = false; m_fontDesc.CharSet = DEFAULT_CHARSET; m_fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS; m_fontDesc.Quality = DEFAULT_QUALITY; m_fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; wcscpy_s(m_fontDesc.FaceName, 256, _T("Verdana")); if(Renderer->getDevice()) D3DXCreateFontIndirect(Renderer->getDevice(), &m_fontDesc, &m_Font); and then i draw like this: static char buffer[256]; sprintf(buffer, "Frames Per Second = %.2f\n" "Milliseconds Per Frame = %.4f\n" "Triangle Count = %d\n" "Vertex Count = %d", m_FPS, m_MilliSecPerFrame, m_NumTris, m_NumVertices); RECT R = {5, 5, 0, 0}; m_Font->DrawTextA(NULL, buffer, -1, &R, DT_NOCLIP, D3DCOLOR_XRGB(255,255,255)); Thx for any hints in advance! Wolfgang

Share this post


Link to post
Share on other sites
Advertisement
Ok solved first problem but still one remaining:-)

First problem was that i somehow got the Backbuffer size messed up so the text got scaled and so it was blury.


Now the text is showing fine for the most part but sometimes the upper part of the line is missing.

Like when it should draw an Equal sign it only draws the lower line and not both lines.

This only happens in Windowed mode.

I think it could be that the Backbuffe ris the total size of the window and not the size of the drawing area.

Any idea how i could fix this?

Thx again:-)

Share this post


Link to post
Share on other sites
Look at the source code for the sample framework; they all make the appropriate choices so that stretching doesn't occur when Present is called.

Share this post


Link to post
Share on other sites
i found this:


m_d3dpp.BackBufferWidth = m_pEnum->m_ScreenWidth;
m_d3dpp.BackBufferHeight = m_pEnum->m_ScreenHeight;
m_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN ;
RECT R = {0, 0, m_pEnum->m_ScreenWidth, m_pEnum->m_ScreenHeight};
AdjustWindowRect(&R, WS_OVERLAPPEDWINDOW, false);
SetWindowLongPtr(hWnd, GWL_style, WS_OVERLAPPEDWINDOW);
SetWindowPos(hWnd, HWND_TOP, 100, 100, R.right, R.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);

But i think its still scaling some in the horizontal direction

Any help would be awsome:-)

Share this post


Link to post
Share on other sites
You'd be better to use AdjustWindowRect when you create the window, rather than retrofitting the window style.

That shouldn't cause any scaling of the backbuffer, you can always take a screenshot and measure the size of the client area and compare that to the reported size of the backbuffer in the present params.

Share this post


Link to post
Share on other sites
Well its definately a scaling problem and it has definately to do with the window size in windowed mode since Fullscreen is working just fine.

Now sine you said resizing the window when i create the d3d device isnt a good idea i thought i would just try to create the window with a diffrent size.

So when i do the following everything works just fine without any scaling problems:

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
DEFAULT_SCREEN_WIDTH + 16 ,
DEFAULT_SCREEN_HEIGHT + 36, GetDesktopWindow(), NULL, hInstance, NULL);

I compared the Backbuffer to the ClientRect and now they are the same size.

But somehow i dont think this is the way to go?

Isnt there a way to create the window with a certain ClientRect so i dont have to add width and height for the window frame?

If there isnt a way to create a window diffrently, can i rely on the +16 and +36 values?

Thx again:-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!