13#ifndef ML_GL_2D_FONT_H
14#define ML_GL_2D_FONT_H
101 const float fontSize,
const float color[4],
102 const char*
string,
const size_t length = 0,
103 const bool overlay=
false,
const bool shadow=
true,
104 const float* shadowColor=
nullptr);
111 const char*
string,
const size_t length)
const;
191 const float fontSize,
const float color[4],
193 const float* shadowColor);
225 std::string _fontfile;
228 std::string _fallback;
237 float _fontSize[MAX_FONTS];
243 bool _unicodeRendering;
246 static GL2DFont* _defaultSystemFont;
A bridge to the ftgl library that manages font rendering with texture fonts.
void doFontDraw(const float dx, const float dy, const float fontSize, const float color[4], const bool shadow, const char *asciiString, const wchar_t *optionalUnicodeString, const float *shadowColor)
Render the fonts.
bool checkUTF8StringForUnicodeChars(const char *string, size_t length=0) const
Check if the string contains unicode chars.
static GL2DFont * getDefaultSystemFont()
get the default system font (already initialized, a valid GL context is only required for the draw me...
int getFontDescender(const float fontSize) const
Get the descender of the font in pixels (positive distance from the baseline).
const char * copyAndConvertString(const char *string, size_t length, const wchar_t **optionalUnicodeString) const
Internal method that copies the string to the internal buffer and generates a unicode string if it is...
int getFontAscender(const float fontSize) const
Get the ascender of the font in pixels.
bool reloadFonts()
Free old fonts and reload them.
void contextDestroyed() override
forget the resource, the context was destroyed (called by the GLResourceManager)
bool isInitialized() const
Returns true if font loaded, otherwise false.
void postFontDraw(const bool overlay)
Finalize the font rendering.
bool init()
Init with the default system font.
void cleanup()
Cleanup the fonts.
std::string findFontFileWithFontconfig(const char *fontName)
Searches the font by using fontconfig (Linux only)
bool debugFontRenderingEnabled()
check if debug font rendering is enabled
void drawString(const float dx, const float dy, const float fontSize, const float color[4], const char *string, const size_t length=0, const bool overlay=false, const bool shadow=true, const float *shadowColor=nullptr)
This function draws a simple string with no linefeeds.
int getFontIndex(const float fontSize) const
Get the font idx that should be used for the given size of the font.
static std::string getDefaultSystemFontName()
returns the default font name for proportional fonts (this can be overwritten via the "GL2DFont_Defau...
bool init(const char *fontname, const int numFonts, const int *sizes)
Init the given font (either just a font name without .ttf or an absolute path) with the given number ...
void preFontDraw(const bool overlay)
Initialize font rendering.
bool isUnicodeRenderingPossible() const
Returns true if unicode rendering is possible, otherwise false.
int getStringWidth(const float fontSize, const char *string, const size_t length) const
Get width of the given simple string.
std::string findFontFile(const char *fontName)
Searches for the file name of the given font.
bool init(const char *fontname)
Init the given font (either just a font name without .ttf or an absolute path).
int getFontHeight(const float fontSize) const
Get the height of a font (ascender+descender) in pixels.
Collection of OpenGL related resource classes, such as textures, buffers, fragment programs etc.
#define ML_OPENGL_END_NAMESPACE
Closes the namespace for all ML stuff after the usage of ML_UTILS_START_NAMESPACE.
#define ML_OPENGL_START_NAMESPACE
Macro to put all following stuff into the namespace ML_NAMESPACE to avoid collisions with symbols of ...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.