Hmm ... I thought this would be simple, but so often are the simple things the ones that take up whole days...
All I want to do is wrap up my fonts (just Windows fonts) in their own class for a game. Piece of cake! Nothing but a bunch of fonts contained in a class, an Init routine which builds the different fonts, and a destructor that deletes them.
Everything appears to be fine except that the wrapped-up "CreateFont" function doesn't seem to be working properly. The following is a public member function of the class:
This function is called in the Init routine like so:
HFONT GameFonts::MakeGameFont(int size, bool italic, char* style, int weight)
HFONT theFont = CreateFont(size, 0, 0, 0, weight,
italic, false, false, ANSI_CHARSET,
PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
Don't mind all the "bool success" stuff, that's just me trying to fingure out what's going on.
bool GameFonts::Init(HDC hdc)
bool success = true;
hfScoreFont = MakeGameFont(-20, true, "times new roman", FW_BOLD);
hfLevelFont = MakeGameFont(-15, false, "arial", FW_BOLD);
Well, the bottom line is this: Something is happening. If I go into the "CreateFont" function and put in the values for size, italic, etc (instead of using the values passed in) then it works, but for some reason the function's not taking the values I pass in! All the fonts are exactly the same! What's up with this? This same function worked perfectly when it was global.