View2DFont Class Reference

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

#include <View2DFont.h>

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 ()
 ~View2DFont ()
bool init (const char *fontname)
 init with given font (either just a font name without .ttf or an absolute path) requires a valid GL context!
bool init (const char *fontname, int numFonts, int *sizes)
 init with given font (either just a font name without .ttf or an absolute path) additionally you can select how many fonts are created internally and in which sizes requires a valid GL context!
int getFontHeight (const float fontSize) const
 get height of font (ascender + descender)
int getFontAscender (const float fontSize) const
 get ascender of font
int getFontDescender (const float fontSize) const
 get descender of font
int getStringWidth (const float fontSize, const char *string, const int len) const
 get width of simple string
void getTextSize (const float fontSize, const char *text, int &width, int &height, float lineSpacing=0.0f) const
 returns size of the box spanned by text box
void drawString (const float dx, const float dy, const float fontSize, const float *color, const char *string, const int length, const bool shadow=true)
 draws a simple string with no linefeeds, the drawing starts at the top-left corner
void drawText (const float dx, const float dy, const float fontSize, const float *color, const char *text, const AlignXMode mode, const 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 32 of file View2DFont.h.


Member Enumeration Documentation

align mode of multi-line text

Enumerator:
ALIGN_LEFT 
ALIGN_RIGHT 
ALIGN_CENTER 

Definition at line 48 of file View2DFont.h.


Constructor & Destructor Documentation

View2DFont::View2DFont (  ) 

View2DFont::~View2DFont (  ) 


Member Function Documentation

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

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

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

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

int View2DFont::getFontAscender ( const float  fontSize  )  const

get ascender of font

int View2DFont::getFontDescender ( const float  fontSize  )  const

get descender of font

int View2DFont::getFontHeight ( const float  fontSize  )  const

get height of font (ascender + descender)

int View2DFont::getStringWidth ( const float  fontSize,
const char *  string,
const int  len 
) const

get width of simple string

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

returns size of the box spanned by text box

bool View2DFont::init ( const char *  fontname,
int  numFonts,
int *  sizes 
)

init with given font (either just a font name without .ttf or an absolute path) additionally you can select how many fonts are created internally and in which sizes requires a valid GL context!

bool View2DFont::init ( const char *  fontname  ) 

init with given font (either just a font name without .ttf or an absolute path) requires a valid GL context!


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

Generated on Sat Sep 3 18:39:33 2011 for MeVisLab Toolbox Reference by  doxygen 1.5.8