Jump to content
  • Advertisement
Sign in to follow this  
learner45

Font drawing problem

This topic is 2492 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,

Im kinda new to DirectX and i have a problem drawing my font.
When i draw a red text, it shows it like that on the screen: JM4ysT.png

Why is that?
Could someone tell me what do i need to do to make it draw correctly?

Thank you.

Share this post


Link to post
Share on other sites
Advertisement
You're going to have to give more detail than that. Which DirectX version you're using and how you're currently drawing text would be a good start. If we don't know what you're doing, how can we explain why it's going wrong?

Share this post


Link to post
Share on other sites
Sorry, i thought it was a default issue of DirectX.
Im using DirectX9.


HDC hDC = GetDC( NULL );
int nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
ReleaseDC( NULL, hDC );
int nHeight = -10 * nLogPixelsY / 72;
D3DXCreateSprite(pDevice, &g_pTextSprite);
D3DXCreateFontA( pDevice, nHeight, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
"Arial", &g_pFont );
DrawText("TEST test 1", 5, 5, 0xFFFF0000, true);




void DrawText(LPCSTR text, int X, int Y, D3DCOLOR Color, bool bBold)
{
g_pTextSprite->Begin(NULL);
RECT rcText7 = {X, Y, 0, 0};
g_pFont->DrawTextA(g_pTextSprite, text, -1, &rcText7, DT_NOCLIP, Color);
g_pTextSprite->End();
}

Share this post


Link to post
Share on other sites
The nHeight isn't really how tall the font should be if it is a positive value, it's how tall the cell of the font is, which is slightly different.
Mostly I guess people who use the Truetype fonts negate it to use the actual height in pixels of the font. The most common thing is to use other
methods to write text, I guess. If you want to use "flashier" Truetype fonts in your game you can include your own in your game and load it from memory
with a few calls, without bothering to have to install it on the target system. For that you can check out the "article" section on my site:

http://http://www.hypermotion.se/articles.html

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!