• Advertisement
Sign in to follow this  

Drawing text with DrawTextA

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

I am using the DrawTextA() function in the ID3DXFont object to draw the text string of the breifings and debreifings of the game. The only problem is the rectangle that i have specified to be the text box isnt in line with the cairrage returns in the string. This means that the text doesnt fit itself into the box, it just cuts off when it goes outside of it. I was wondering if there is a way i could set this function or use a different one to cleanly format the string into the desired box withought me going in and manually putting all the cairrage returns in the right spot.

Share this post


Link to post
Share on other sites
Advertisement
First, I would recommend you don't call DrawTextA directly, call DrawText and let the compiler worry about if this build uses ascii string (therefore DrawTextA) or unicode (DrawTextW).

To solve your problem, simply add DT_WORDBREAK to your Format parameter to get it to automatically insert newlines to fit the box. It takes care of making sure they fall in sensible places like in between words.

Alan

Share this post


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

  • Advertisement