13#ifndef ML_GL_2D_FONT_H
14#define ML_GL_2D_FONT_H
73 bool init(
const char* fontname);
81 bool init(
const char* fontname,
int numFonts,
const int* sizes);
102 void drawString(
float dx,
float dy,
float fontSize,
const float color[4],
const char*
string,
size_t length = 0,
103 bool overlay =
false,
bool shadow =
true,
104 const float* shadowColor =
nullptr);
143 return _unicodeRendering;
195 void doFontDraw(
float dx,
float dy,
float fontSize,
const float color[4],
bool shadow,
196 const char* asciiString,
const wchar_t* optionalUnicodeString,
const float* shadowColor);
213 const char*
copyAndConvertString(
const char*
string,
size_t length,
const wchar_t** optionalUnicodeString)
const;
228 std::string _fontfile;
231 std::string _fallback;
246 bool _unicodeRendering;
249 static GL2DFont* _defaultSystemFont;
bool checkUTF8StringForUnicodeChars(const char *string, size_t length=0) const
Checks whether the string contains unicode chars.
static GL2DFont * getDefaultSystemFont()
void drawString(float dx, float dy, float fontSize, const float color[4], const char *string, size_t length=0, bool overlay=false, bool shadow=true, const float *shadowColor=nullptr)
const char * copyAndConvertString(const char *string, size_t length, const wchar_t **optionalUnicodeString) const
bool init(const char *fontname, int numFonts, const int *sizes)
bool reloadFonts()
Frees old fonts and reloads them.
void contextDestroyed() override
Forgets the resource, the context was destroyed (called by the GLResourceManager).
bool isInitialized() const
Returns true if font loaded; otherwise, it returns false.
void postFontDraw(const bool overlay)
Finalizes the font rendering.
int getFontAscender(float fontSize) const
int getFontDescender(float fontSize) const
void cleanup()
Cleans up the fonts.
std::string findFontFileWithFontconfig(const char *fontName)
Searches the font by using fontconfig (Linux only).
bool debugFontRenderingEnabled()
Checks whether debug font rendering is enabled.
int getFontIndex(float fontSize) const
Returns the font index that should be used for the given size of the font.
int getFontHeight(float fontSize) const
static std::string getDefaultSystemFontName()
void preFontDraw(bool overlay)
Initializes font rendering.
void doFontDraw(float dx, float dy, float fontSize, const float color[4], bool shadow, const char *asciiString, const wchar_t *optionalUnicodeString, const float *shadowColor)
Renders the fonts.
bool isUnicodeRenderingPossible() const
Returns true if Unicode rendering is possible; otherwise, it returns false.
std::string findFontFile(const char *fontName)
int getStringWidth(float fontSize, const char *string, int length=-1) const
bool init(const char *fontname)
#define ML_OPENGL_END_NAMESPACE
Closes the namespace for all ML code after the usage of ML_UTILS_START_NAMESPACE.
#define ML_OPENGL_START_NAMESPACE