Creating a flexible font class

Started by
0 comments, last by DrunkenHyena 19 years, 5 months ago
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?
Ethereal
Advertisement
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.
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement