Sign in to follow this  
Roxypinky

How to measure string length in pixel

Recommended Posts

Roxypinky    100
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

Share this post


Link to post
Share on other sites
ET3D    810
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.

Share this post


Link to post
Share on other sites
Roxypinky    100
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 :)

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