Jump to content
  • Advertisement
Sign in to follow this  

Creating a flexible font class

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

I just can't ignore it any more; i need to implement some awesome text-routines to my engine instead of the backside-of-the-moon-ugly hack i've implemented atm. I've got some old routines in some even older projects that'll work something like this:
FontMgr* font_mgr = new FontMgr();

// params: face name, font id, bold, size
font_mgr->add_font("arial", "arial_bold_12", true, 12);
font_mgr->add_font("arial", "arial_12", false, 12);

font_mgr->draw("hello, i'm a fat arial text with size 12", 100, 100);

This class is pretty decent for simple text like debugging and minor hud-text, but there is one thing i don't like about it: I can not load fonts as resources (e.g "data\fonts\font.ttf") but only directly from the %windows%\fonts directory. This is pretty restricting because I have to install my custom fonts to the users directory and I don't want that, I want my font to be game-specific only so I need to load it as a resource. can someone point me to some hints to load fonts as resources?

Share this post

Link to post
Share on other sites
You can put the fonts in your game directory and load them from there. They have to be added to the system font list which can be done using a GDI call. Flip through MSDN for font functions and you should find it.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!