- #ifndef FONTMANAGER_H
- #define FONTMANAGER_H
- #include <UECommon/Defines.h>
- #include <ft2build.h>
- #include FT_FREETYPE_H
- #include <map>
- #include <vector>
- #include <string>
- namespace UERenderer
- {
- enum SpecialChar
- {
- NONE,
- SPACE,
- };
- struct CharInfo
- {
- CharInfo(std::string ptextureName, size_t pu, size_t pv,
- size_t pwidth, int pymin, int pymax,
- SpecialChar pspecialChar = NONE)
- {textureName = ptextureName; u = pu; v = pv; width = pwidth;
- ymin = pymin; ymax = pymax; specialChar = pspecialChar;}
- std::string textureName;
- size_t u;
- size_t v;
- size_t width;
- int ymin;
- int ymax;
- enum SpecialChar specialChar;
- };
- struct TextInfo
- {
- TextInfo()
- {
- width = 0;
- height = 0;
- }
- std::vector<CharInfo> charInfoList;
- size_t width;
- size_t height;
- int yminMax;
- };
- class UE_API FontManager
- {
- public:
- static FontManager* getInstance();
- TextInfo getString(const std::string &string);
- private:
- FontManager();
- ~FontManager();
- CharInfo getCharInfo(unsigned long unicodeChar);
- void generateNewTexture();
- private:
- static FontManager minstance;
- std::vector<std::string> mtextureList;
- std::map<unsigned long, CharInfo> mcharMap;
- size_t mcurU;
- size_t mcurV;
- int mcurTexture;
- int mlineHeight;
- size_t mtextureWidth;
- size_t mtextureHeight;
- FT_Library mlibrary;
- FT_Face mface;
- };
- }
- #endif