Sign in to follow this  

Calculating Text width in pixel using D3DXFont

Recommended Posts

How do i calculate the exact width and height of the text to be rendered by D3DXFont::DrawText() I think i need to use the D3DXFont::GetGlyphData() but not sure how

Share this post

Link to post
Share on other sites
From the DX docs for ID3DXFont::DrawText:

[in] Specifies the method of formatting the text. It can be any combination of the following values:
Determines the width and height of the rectangle. If there are multiple lines of text, ID3DXFont::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DXFont::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DXFont::DrawText returns the height of the formatted text but does not draw the text.

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