Sign in to follow this  

Creating a flexible font class

This topic is 4780 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->select_font("arial_bold_12");
font_mgr->prepare();
font_mgr->draw("hello, i'm a fat arial text with size 12", 100, 100);
font_mgr()->present()

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

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