How to measure string length in pixel

Started by
2 comments, last by Roxypinky 14 years, 2 months ago
Hello, Is it possible to know how big a piece of text will be on screen depending of the font I'm using with unmanaged DirectX? Every article on this I've found so far are in managed code. Thanks, -Roxanne
Advertisement
check out GetTextExtentPoint32
Assuming you're using Direct3D 9 and ID3DXFont to draw the text, then calling ID3DXFont::DrawText with DT_CALCRECT for the Format parameter will return the rectangle that will be used, as described in the docs for that function. If you're using something else, then some details would help.
Yes that's what i'm using. I was looking on msdn for something like a MeasureString method or something... didnt think of looking the flags for DrawText. Thanks a lot :)

This topic is closed to new replies.

Advertisement