Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Font drawing problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 learner45   Members   -  Reputation: 99

Like
0Likes
Like

Posted 11 February 2012 - 09:01 AM

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: Posted Image

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

Thank you.

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 6671

Like
0Likes
Like

Posted 11 February 2012 - 09:20 AM

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?

#3 learner45   Members   -  Reputation: 99

Like
0Likes
Like

Posted 11 February 2012 - 09:44 AM

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();
}


#4 Anders2   Members   -  Reputation: 127

Like
0Likes
Like

Posted 15 February 2012 - 12:21 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS