Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Crazy font occurance

This topic is 5920 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

Okay, so my problem is this. When I use RenderFont in one place, it works okay. But when if I use it again later on, in another .cpp file, and specify a different size, the second RenderFont call''s size parameter is ignored. The placement is correct, but it ends up the size of the first one. The strange thing is, this size change only happens if I wait long enough. That is, if I run through the game sequence quickly, the fonts all appear the size they should be. Any help is greatly appreciated. Here is what my "font engine" looks like. //Declare our D3DXFont interface pointer ID3DXFont* fontPointer = NULL; extern IDirect3DDevice8* D3D_Device; void InitFont(int size) { HRESULT hr; //our LOGFONT structure defines the font we''re requesting. LOGFONT logFont={ size, //height 0, //width; 0, //lfEscapement; 0, //lfOrientation; FALSE, // lfWeight; FALSE, // lfItalic; FALSE, // lfUnderline; FALSE, // lfStrikeOut; DEFAULT_CHARSET, // lfCharSet; OUT_DEFAULT_PRECIS, //lfOutPrecision; CLIP_DEFAULT_PRECIS, // lfClipPrecision; ANTIALIASED_QUALITY,// lfQuality; DEFAULT_PITCH,// lfPitchAndFamily; "Times New Roman"// lfFaceName[LF_FACESIZE]; }; hr=D3DXCreateFontIndirect(D3D_Device,&logFont,&fontPointer); } void KillFont(void){ if(fontPointer) { fontPointer->Release(); fontPointer=NULL; } } void RenderFont(char* text, int xPosition, int yPosition, int size) { //We want the font to be formated to the whole screen RECT fontRect={0,0,800,600}; InitFont(size); fontPointer->Begin(); //Set the position for text rendering. fontRect.top = yPosition; fontRect.left = xPosition; fontPointer->DrawText(text,-1 , fontRect , DT_LEFT ,0xFFFFFFFF fontPointer->End(); }//end RenderFont()

Share this post

Link to post
Share on other sites

  • 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!