7 #include <unordered_map>
24 using std::unordered_map;
51 unordered_map<uint32_t, GUICharacter*>
chars;
64 GUIFont(
const string& pathName,
const string& fileName,
int size);
78 auto updatedTextureAtlas =
false;
80 while (u8It.
hasNext() ==
true) {
81 auto characterId = u8It.
next();
82 if (characterId == -1)
continue;
85 updatedTextureAtlas =
true;
111 static GUIFont*
parse(
const string& pathName,
const string& fileName,
int size);
142 if (charId == -1)
return nullptr;
144 auto charIt =
chars.find(charId);
145 if (charIt !=
chars.end())
return charIt->second;
232 void drawString(
GUIRenderer* guiRenderer,
int x,
int y,
const MutableString& text,
int offset,
int length,
const GUIColor& color,
int selectionStartIndex = -1,
int selectionEndIndex = -1,
const GUIColor& backgroundColor = GUIColor::GUICOLOR_TRANSPARENT);
GUI screen node that represents a screen that can be rendered via GUI system.
void drawString(GUIRenderer *guiRenderer, int x, int y, const MutableString &text, int offset, int length, const GUIColor &color, int selectionStartIndex=-1, int selectionEndIndex=-1, const GUIColor &backgroundColor=GUIColor::GUICOLOR_TRANSPARENT)
Draw string.
GUICharacter * getCharacter(uint32_t charId)
Get character defintion.
unordered_map< uint32_t, GUICharacter * > chars
GUICharacter * addToTextureAtlas(uint32_t charId)
Add character with given id to texture atlas.
void drawCharacter(GUIRenderer *guiRenderer, GUICharacter *character, int x, int y, const GUIColor &color=GUIColor::GUICOLOR_WHITE)
Draw character.
void drawCharacterBackground(GUIRenderer *guiRenderer, GUICharacter *character, int x, int y, int lineHeight, const GUIColor &color)
Draw background.
vector< uint8_t > ttfData
int getTextIndexX(const MutableString &text, int offset, int length, int index)
Get text index X of given text and index.
int getTextIndexByX(const MutableString &text, int offset, int length, int textX)
Get text index by text and X in space of text.
void updateFontInternal()
Do the update work.
static bool ftInitialized
static FT_Library ftLibrary
TextureAtlas textureAtlas
GUIFont(const string &pathName, const string &fileName, int size)
Public constructor.
void addCharactersToFont(const string &text)
Update texture atlas.
static GUIFont * parse(const string &pathName, const string &fileName, int size)
Parse the font definition file.
void updateFont()
Update font texture atlas and character definitions.
int getTextIndexXAtWidth(const MutableString &text, int width)
Get text index X at width.
int getTextWidth(const MutableString &text)
Text width.
Mutable utf8 aware string class.
UTF8 string character iterator.
#define FORBID_CLASS_COPY(CLASS)