• 10
• 9
• 13
• 10
• 18

# (SlimDX)Issues with font size.

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

## 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 on other sites
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 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....