Initial commit. Not even a game yet :P
[cToan.git] / src / SDLWrap_Font.hpp
blobace3bffe687b262a3c95dae586edb3cf7eb104ef
1 #ifndef _SDLWRAP_FONT_H_
2 #define _SDLWRAP_FONT_H_
4 #include "SDL/SDL.h"
5 #include "SDL/SDL_ttf.h"
7 #include "ErrorHandler.hpp"
9 namespace SDLWrap {
11 class Font {
12 public:
13 /* This exception is thrown when a font could not be loaded for some reason, either because it wasn't a font or
14 * the path to the TTF file is invalid. It is also thrown in the case that the TTF system could not be loaded.
16 class TTFError {};
18 /* Typical constructor that opens a TTF font file using TTFFilePath and sets it to render at size FontSize.
19 * Throws a TTFError in case the TTF system could not be loaded (Only happens when the first font is loaded or
20 * if you try to load a font when the TTF system is not running, more generally as you can call Shutdown() then
21 * load a font. Also keeps a refcount using FontCount.
23 Font(const std::string TTFFilePath, const int FontSize);
25 /* Just frees the memory used by the Font and decrements FontCount. */
26 ~Font();
28 /* In case you want to shutdown the TTF system, just call this. It will only shutdown if there are no fonts in
29 * memory, which it checks by comparing FontCount.
31 static void Shutdown();
33 public:
34 TTF_Font *me; // Publicize it so FontSurface can use it in it's rendering schemes.
36 private:
37 static int FontCount;
38 std::string FilePath;
43 #endif