MeVisLab Toolbox Reference
|
Abstract GL font drawing using FTGL. More...
#include <View2DFont.h>
Public Types | |
enum | AlignXMode { ALIGN_LEFT , ALIGN_RIGHT , ALIGN_CENTER } |
align mode of multi-line text More... | |
Public Member Functions | |
View2DFont () | |
virtual | ~View2DFont () |
virtual bool | init (const char *fontname=nullptr)=0 |
init with given font (either just a font name without .ttf or an absolute path) requires a valid GL context! | |
virtual int | getFontHeight (float fontSize) const =0 |
get height of font (ascender + descender) | |
virtual int | getFontAscender (float fontSize) const =0 |
get ascender of font | |
virtual int | getFontDescender (float fontSize) const =0 |
get descender of font | |
virtual int | getStringWidth (float fontSize, const char *string, int len) const =0 |
get width of simple string | |
virtual void | drawString (float dx, float dy, float fontSize, const float *color, const char *string, int length, bool shadow=true, const float *shadowColor=nullptr, bool flipped=false)=0 |
draws a simple string with no linefeeds, the drawing starts at the top-left corner color needs to point to a float[4] array (RGBA) shadowColor is optional and needs to point to a float[3] array (RGB), alpha is taken from color . | |
void | drawStringFlipped (float dx, float dy, float fontSize, const float *color, const char *string, int length, bool shadow=true, const float *shadowColor=nullptr) |
as above for drawing a string up-side down where you don't need to specify all parameters | |
virtual void | getTextSize (float fontSize, const char *text, int &width, int &height, float lineSpacing=0.0f) const |
returns size of the box spanned by text box | |
virtual void | drawText (float dx, float dy, float fontSize, const float *color, const char *text, AlignXMode mode, bool shadow=true, float lineSpacing=0.0f, const float *shadowColor=nullptr) |
draws a multi-line text, lines are separated by , the drawing starts at the top-left corner. | |
Static Public Member Functions | |
static View2DFont * | globalFont () |
get the global font used for annotations etc. (only call this within a valid GL context!) | |
static View2DFont * | createFont (const char *fontname=nullptr) |
create a new font object with the given font name (/see init). | |
Abstract GL font drawing using FTGL.
This is the extended version of mlGL2DFont (from MLOpenGL). Most calls are bridged towards mlGL2DFont, but it additionally features rendering of larger text blocks including line feeds. All strings are expected to be in UTF8 encoding.
The above figure illustrates how the fonts are rendered. The rendering starts at the top-left (x,y). The height of the font is given by the sum of ascender and descender.
Definition at line 29 of file View2DFont.h.
align mode of multi-line text
Enumerator | |
---|---|
ALIGN_LEFT | |
ALIGN_RIGHT | |
ALIGN_CENTER |
Definition at line 36 of file View2DFont.h.
View2DFont::View2DFont | ( | ) |
|
virtual |
|
static |
create a new font object with the given font name (/see init).
If no fontname is given, this uses the same font as globalFont(). The caller becomes the owner of the object.
Only call this within a valid GL context!
|
pure virtual |
draws a simple string with no linefeeds, the drawing starts at the top-left corner color
needs to point to a float[4] array (RGBA) shadowColor
is optional and needs to point to a float[3] array (RGB), alpha is taken from color
.
flipped
if set draws the string up-side down (for those cases where the coordinate system is not flipped from the OpenGL default)
Implemented in View2DFontFTGL, and View2DFontQt.
|
inline |
as above for drawing a string up-side down where you don't need to specify all parameters
Definition at line 65 of file View2DFont.h.
References mlrange_cast().
|
virtual |
draws a multi-line text, lines are separated by
, the drawing starts at the top-left corner.
color
needs to point to a float[4] array (RGBA) shadowColor
is optional and needs to point to a float[3] array (RGB), alpha is taken from color
.
get ascender of font
Implemented in View2DFontFTGL, and View2DFontQt.
get descender of font
Implemented in View2DFontFTGL, and View2DFontQt.
get height of font (ascender + descender)
Implemented in View2DFontFTGL, and View2DFontQt.
|
pure virtual |
get width of simple string
Implemented in View2DFontFTGL, and View2DFontQt.
|
virtual |
returns size of the box spanned by text box
|
static |
get the global font used for annotations etc. (only call this within a valid GL context!)
init with given font (either just a font name without .ttf or an absolute path) requires a valid GL context!
Implemented in View2DFontFTGL, and View2DFontQt.