MeVisLabToolboxReference
View2DFont Class Reference

This is the extended version of mlGL2DFont (from MLOpenGL). More...

#include <View2DFont.h>

Inheritance diagram for View2DFont:
View2DFontFTGL View2DFontQt

List of all members.

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=NULL)=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)=0
 draws a simple string with no linefeeds, the drawing starts at the top-left corner
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)
 draws a multi-line text, lines are separated by
, the drawing starts at the top-left corner

Detailed Description

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.

fontexample.png
Font rendering of all draw methods starts at top-left (x,y).

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 26 of file View2DFont.h.


Member Enumeration Documentation

align mode of multi-line text

Enumerator:
ALIGN_LEFT 
ALIGN_RIGHT 
ALIGN_CENTER 

Definition at line 33 of file View2DFont.h.


Constructor & Destructor Documentation

View2DFont::View2DFont ( )
virtual View2DFont::~View2DFont ( ) [virtual]

Member Function Documentation

virtual void View2DFont::drawString ( float  dx,
float  dy,
float  fontSize,
const float *  color,
const char *  string,
int  length,
bool  shadow = true 
) [pure virtual]

draws a simple string with no linefeeds, the drawing starts at the top-left corner

Implemented in View2DFontFTGL, and View2DFontQt.

virtual void View2DFont::drawText ( float  dx,
float  dy,
float  fontSize,
const float *  color,
const char *  text,
AlignXMode  mode,
bool  shadow = true,
float  lineSpacing = 0.0f 
) [virtual]

draws a multi-line text, lines are separated by
, the drawing starts at the top-left corner

virtual int View2DFont::getFontAscender ( float  fontSize) const [pure virtual]

get ascender of font

Implemented in View2DFontFTGL, and View2DFontQt.

virtual int View2DFont::getFontDescender ( float  fontSize) const [pure virtual]

get descender of font

Implemented in View2DFontFTGL, and View2DFontQt.

virtual int View2DFont::getFontHeight ( float  fontSize) const [pure virtual]

get height of font (ascender + descender)

Implemented in View2DFontFTGL, and View2DFontQt.

virtual int View2DFont::getStringWidth ( float  fontSize,
const char *  string,
int  len 
) const [pure virtual]

get width of simple string

Implemented in View2DFontFTGL, and View2DFontQt.

virtual void View2DFont::getTextSize ( float  fontSize,
const char *  text,
int &  width,
int &  height,
float  lineSpacing = 0.0f 
) const [virtual]

returns size of the box spanned by text box

virtual bool View2DFont::init ( const char *  fontname = NULL) [pure virtual]

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.


The documentation for this class was generated from the following file: