How can I get the exact width of a character ???
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 ???
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.
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 ???
Quote:Original post by ArthY303No, it just gets the size of the string.
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 ???
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 ???
I have another question though : is there any way to find out how many pixels does the DrawText() function puts between lines ???
This should do it:
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).
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement