Sign in to follow this  
ArthY303

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

Recommended Posts

Evil Steve    2017
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
Evil Steve    2017
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
Evil Steve    2017
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this