13#ifndef ML_GL_2D_FONT_H
14#define ML_GL_2D_FONT_H
26ML_OPENGL_START_NAMESPACE
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;
252ML_OPENGL_END_NAMESPACE
bool checkUTF8StringForUnicodeChars(const char *string, size_t length=0) const
Checks whether the string contains unicode chars.
bool isUnicodeRenderingPossible() const
Returns true if Unicode rendering is possible; otherwise, it returns false.
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)
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.
int getFontAscender(float fontSize) const
void postFontDraw(const bool overlay)
Finalizes the font rendering.
static std::string getDefaultSystemFontName()
bool reloadFonts()
Frees old fonts and reloads them.
std::string findFontFile(const char *fontName)
bool init(const char *fontname)
void contextDestroyed() override
Forgets the resource, the context was destroyed (called by the GLResourceManager).
static GL2DFont * getDefaultSystemFont()
const char * copyAndConvertString(const char *string, size_t length, const wchar_t **optionalUnicodeString) const
bool debugFontRenderingEnabled()
Checks whether debug font rendering is enabled.
std::string findFontFileWithFontconfig(const char *fontName)
Searches the font by using fontconfig (Linux only).
bool init(const char *fontname, int numFonts, const int *sizes)
int getStringWidth(float fontSize, const char *string, int length=-1) const
int getFontDescender(float fontSize) const
int getFontHeight(float fontSize) const
void preFontDraw(bool overlay)
Initializes font rendering.
bool isInitialized() const
Returns true if font loaded; otherwise, it returns false.
void cleanup()
Cleans up the fonts.
int getFontIndex(float fontSize) const
Returns the font index that should be used for the given size of the font.
#define MLOPENGL_EXPORT
Closes the namespace for all ML code after the usage of ML_UTILS_START_NAMESPACE.