Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

andy1

Deleting DirectX Fonts from Memory

This topic is 5230 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. I am making a UI editor with DirectX that uses fonts to draw text on the controls. Every frame, I check to make sure that all fonts are being used, and delete the fonts that are not. I can call this code, which is supposed to remove the font from system/video memory: Font.Dispose() Font = Nothing However, it does not really delete it, and when I have a lot of fonts loaded, it makes it very slow (30 controls can eventually create 1000 fonts if the unused fonts are not deleted). Eventually, my program just stops responding because there are too many fonts. But when I resize the form (which deletes all the fonts because the device has changed), things speed up again. I thought I could call Font.OnLostDevice(), but that causes an error (maybe because it unloads all the other fonts?) I need a way to remove the fonts from memory without resizing the device.

Share this post


Link to post
Share on other sites
Advertisement
Why not create about 3 or 4 types of fonts in your main GUI
object and let controls have pointers to them?

Share this post


Link to post
Share on other sites
Because I want to let the user to choose what fonts he/she wants on each control. Of course, I could have a limited selection of fonts and styles, but I don''t want to go there unless I have to.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Is it possible to set it up using and unsized array. In C#, you could create and ArrayList, then have a Font[] = new Font[ArrayList.Count] then a for loop to go through check to find empty slots, that are unused, and dispose of them and then fill them with the new font.

Share this post


Link to post
Share on other sites
Sounds like you''re in dire need of a font ''pool.'' You may want to let the user set the font for each individual control, but what are the chances that they''ll want a different font for each of 1000 controls?

Instead I''d recommend you keep a global array of fonts, and reuse them for controls that have the same fonts.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!