Direct3D Font sizes

Started by
7 comments, last by Anon Mike 15 years, 5 months ago
Hello people, was just wondering if the font sizes in direct3d as in other applications. for example will i get the same size text in direct3d as i would in microsoft word if using the same Em's
Advertisement
Yes, ID3DXFont uses GDI for font rendering, the same as MS Word. So, provided you give the same parameters to D3DXCreateFont, you'll get the same output.
Hum, well this isnt the case with my font class, for some reason the font at 12 em's is much smaller than the same font in microsoft word, at the same size, also when drawing text my text becomes "choppy" meaning parts of the letters are not drawing or draw incorrectly. the parameters for my font object are basicly the "default" but as i have said its not drawing correctly. what could cause this?

unfortunatly i cant post code at this momment as im in college waiting for my tutor to turn up (im a bit early lol)

Thanks for the reply
~Reegan
Quote:Original post by Reegan
Hum, well this isnt the case with my font class, for some reason the font at 12 em's is much smaller than the same font in microsoft word, at the same size, also when drawing text my text becomes "choppy" meaning parts of the letters are not drawing or draw incorrectly. the parameters for my font object are basicly the "default" but as i have said its not drawing correctly. what could cause this?

unfortunatly i cant post code at this momment as im in college waiting for my tutor to turn up (im a bit early lol)

Thanks for the reply
~Reegan
Sounds to me like you're not specifying the font size in points, but in pixels. Are you converting from point size to pixels using the method the Documentation uses:
nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
?
That code is to do with GDI, why isnt this procedure of converting pixels to points done in the ID3DXFont::D3DXCreateFont(...) method?

since i do not have handle to the device context, this would not work anyway.
Quote:Original post by Reegan
That code is to do with GDI, why isnt this procedure of converting pixels to points done in the ID3DXFont::D3DXCreateFont(...) method?

ID3DXFont uses GDI internally, and fonts are GDI objects. Logical units (Device "pixels") are the correct scale to use for fonts, not point size. From the Documentation:
Quote:Height
[in] The height of the characters in logical units.


Quote:Original post by Reegan
since i do not have handle to the device context, this would not work anyway.
GetDC(NULL)
Well, ok, ill try it out when i get home. But i dont see why i have to carry out that conversion manually when it could have easily been done inside the ID3DXFont::D3DXCreateFont(...) function.

Thanks ^^
~Reegan
Quote:Original post by Reegan
Well, ok, ill try it out when i get home. But i dont see why i have to carry out that conversion manually when it could have easily been done inside the ID3DXFont::D3DXCreateFont(...) function.
I guess it's to keep things the same between GDI fonts and D3D fonts; D3D would have to convert from point size to pixels to pass to GDI, and the usual units for fonts are logical units rather than point sizes - it'd be like expecting ID3DXFont::DrawText to take HSV values for colour instead of RGB.

I feel your pain though, I had the same problems when I started doing font stuff [smile]
Quote:Original post by Reegan
why isnt this procedure of converting pixels to points done in the ID3DXFont::D3DXCreateFont(...)

Because not everybody uses points.

It's actually pretty common for people to say "I want this font to 12px high". Or "I've got this graphics element that I want to squeeze text into and I don't really care how big it is". There's even still a few oddballs out there that use pica.

Since the unit is arbitrary they just went with the simplest thing which is to use what the layer beneath them uses.
-Mike

This topic is closed to new replies.

Advertisement