Sign in to follow this  
Reegan

Direct3D Font sizes

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);
?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

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