Jump to content
  • Advertisement
Sign in to follow this  
jdub

(SlimDX)Issues with font size.

This topic is 2810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying figure out how wide in pixels a block of monospace text is (amount of characters X width of each character). However, the width is coming out as 0. Looking in the editor, I can see that the width of the font given by the font description is coming out as zero. What am I doing wrong?

Code Snippets:



//Creation Code
font = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font(FontFamily.GenericMonospace, 12));
//....
//Draw Code
font.DrawString(sprite, "Hello World", new Rectangle(0,0,font.Description.Width * 11, font.Description.Height), DrawTextFormat.Center, new Color4(Color.White) );

Share this post


Link to post
Share on other sites
Advertisement
The values of those fields reflect the values of the D3DXFONT_DESC structure which, as noted on that page, reflect the values of the LOGFONT structure.

As you can see in the LOGFONT structure, the [font=Consolas, Courier, monospace][size=2]lfWidth and [/font][font=Consolas, Courier, monospace][size=2]lfHeight members can both be 0.[/font]

Share this post


Link to post
Share on other sites
So.... if my font has a width of zero according to the structure, how would I find what the width in pixels would be.

MSDN says that if the width is zero: the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference.


confused on what this means....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!