/*! * \file include/system/FontTTF.h * \brief TrueType Font Implementation * * \author xythobuz */ #ifndef _FONT_TTF_H_ #define _FONT_TTF_H_ #include #include #include "stb/stb_truetype.h" #include "system/Shader.h" class FontMapTTF { public: FontMapTTF(); FontMapTTF(FontMapTTF&& other); ~FontMapTTF(); int initialize(unsigned char* fontData, int firstChar); bool contains(int c); int getTexture() { return texture; } void getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad); private: int begin; int texture; stbtt_packedchar* charInfo; }; class FontTTF { public: static int initialize(std::string f); static void shutdown(); static unsigned int widthText(float scale, std::string s); static unsigned int heightText(float scale, unsigned int maxWidth, std::string s); static void drawText(unsigned int x, unsigned int y, float scale, glm::vec4 color, std::string s); static void drawTextWrapped(unsigned int x, unsigned int y, float scale, glm::vec4 color, unsigned int maxWidth, std::string s); private: static int charIsMapped(int c); static int getQuad(int c, float* xpos, float* ypos, stbtt_aligned_quad* quad); static void drawTextInternal(unsigned int x, unsigned int y, float scale, glm::vec4 color, unsigned int maxWidth, std::string s, bool drawWrapped); static unsigned char* fontData; static std::vector maps; static ShaderBuffer vertexBuffer; static ShaderBuffer uvBuffer; }; #endif