Jump to content
  • Advertisement
Sign in to follow this  

How can I get the exact width of a character ???

This topic is 3563 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 ID3DXFONT interface and I want to find the exact width of a character no matter the font. Or the width of the widest character in the font. Can someone help me or at least point me in the right direction ???

Share this post


Link to post
Share on other sites
Advertisement
Calling DrawText() with the DT_CALCRECT flag will cause ID3DXFont to update the RECT you passed in with the size of the text, so you can just use that flag and call DrawText() with a single character.

Share this post


Link to post
Share on other sites
Does calling DrawText() with DT_CALCRECT result in displaying text on the screen or is it just used to get the width of a string ???

Share this post


Link to post
Share on other sites
Quote:
Original post by ArthY303
Does calling DrawText() with DT_CALCRECT result in displaying text on the screen or is it just used to get the width of a string ???
No, it just gets the size of the string.

Share this post


Link to post
Share on other sites
Thanks for the quick response ... and it actually solved my problem.
I have another question though : is there any way to find out how many pixels does the DrawText() function puts between lines ???

Share this post


Link to post
Share on other sites
This should do it:

TEXTMETRIC tm;
GetTextMetrics(pFont->GetDC(), &tm);
// tm.tmHeight is the height of one line of text


I'm not entirely sure if that's correct though, you'd have to try it and see (I use my own font renderer rather than ID3DXFont).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!