Sign in to follow this  

Should i be useing ID3DXFont?

This topic is 3202 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

Hello everyone, While experimenting i have written a little Terrain Editor. But now i would like to add a GUI to it. So i was going to implement a gui system next. Its going to be in directx and c++ but i was wondering how i should do fonts. so far for testing i used ID3DXFont but i am not sure if i can load special fonts with that interface so i was wondering if i should keep useing ID3DXFont or implement bitmap fonts or maybe use something else i didnt think about yet:-) If anyone had some hints for me it would be much apreciated! Thx a lot in advance!:-) Wolfgang

Share this post


Link to post
Share on other sites
You can use any font with the ID3DXFont,those that are inside the windows font folder for example.
You can also add new fonts and use them with ID3DXFont.


AddFontResource("myNewFont.ttf");
SendMessage(HWND_BROADCAST,WM_FONTCHANGE, 0, 0 );

Then use "myNewFont.ttf" in the D3DXCreateFont call as the facename.

Share this post


Link to post
Share on other sites
Well there's 2 main issues with ID3DXFont:

-Since it uses GDI to draw the text to a texture and draws it as a sprite, the computer running your app needs to have the font installed at runtime
-Also because of the fact that it uses GDI, it's not particularly fast

Pre-drawing fonts to textures and then using those at runtime can take care of those two issues. However you still need to watch out for copyright issues...

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
-Since it uses GDI to draw the text to a texture and draws it as a sprite, the computer running your app needs to have the font installed at runtime
-Also because of the fact that it uses GDI, it's not particularly fast
The first can be addressed by using AddFontMemResourceEx to add a font that can then be used by ID3DXFont. That allows you to bundle the font with your app as a data file, or include it as a resource.
The second isn't entirely true - ID3DXFont renders glyphs to the alpha channel of 256x256 textures. Last time I checked, it doesn't make very good use of the texture (Doesn't pack the glyphs very well), and it locks the entire texture to add a single glyph (Instead of a small region). For rendering, it should be about as fast as you can get; it just submits sprites to the ID3DXFont you pass, which are then rendered as an indexed triangle list.

I made a Journal Entry a while ago about what it does in the innards - although bear in mind that it's all from a reasonably old SDK.

Share this post


Link to post
Share on other sites

This topic is 3202 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.

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