aboutsummaryrefslogtreecommitdiffstats
path: root/include/font.hpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-04-27 17:40:12 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-04-27 17:40:12 -0400
commita33b3d4ffc1defda5bdcd3348036ce48ef5b0085 (patch)
tree87070680ba9c8a02a2c9a6184f22e5cb0f466b55 /include/font.hpp
parent00f879600bcea8f1ec1775c941041ee6346a60ba (diff)
modernized ui
Diffstat (limited to 'include/font.hpp')
-rw-r--r--include/font.hpp56
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_