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) );
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=Consolas, Courier, monospace][size=2]lfHeight members can both be 0.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
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.