diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2017-04-27 21:33:13 -0400 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2017-04-27 21:33:13 -0400 |
commit | 2de1af94cfa794ae5dd7913c797d673b58289949 (patch) | |
tree | 3acb4e822943efb714ff04d4e88307127e34f52e /include/font.hpp | |
parent | 40f2ab396ccca1a12cc74d18c9758da5bc2f1afc (diff) | |
parent | 00de7a4b0aa48c3cb42c45e0f203902ca034b94c (diff) |
Updated sprites
Diffstat (limited to 'include/font.hpp')
-rw-r--r-- | include/font.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/font.hpp b/include/font.hpp new file mode 100644 index 0000000..a520c15 --- /dev/null +++ b/include/font.hpp @@ -0,0 +1,56 @@ +#ifndef FONT_HPP_ +#define FONT_HPP_ + +#include <vector> +#include <map> + +#include <color.hpp> +#include <render.hpp> +#include <vector2.hpp> + +#include <ft2build.h> +#include FT_FREETYPE_H + +struct FT_Info { + vec2 wh; + vec2 bl; + vec2 ad; + GLuint tex; + + FT_Info(void) + : tex(0) {} +}; + +class FontSystem { +private: + static FT_Library ftLibrary; + static FT_Face ftFace; + + static std::string fontFamily; + static std::map<int, std::vector<FT_Info>> fontData; + + static int currentSize; + static Color currentColor; + static float currentZ; + +public: + ~FontSystem(void) { + FT_Done_Face(ftFace); + FT_Done_FreeType(ftLibrary); + } + + static void init(const std::string& ttf); + static void setFontSize(int size); + static void setFontColor(float r, float g, float b); + static void setFontZ(float z = -8.0f); + + static vec2 putChar(float xx, float yy, char c); + + static inline int getSize(void) + { return currentSize; } + + static inline auto& getFont(void) + { return fontData.at(currentSize); } +}; + +#endif // FONT_HPP_ |