FTFont Class Reference

#include <FTFont.h>

Inheritance diagram for FTFont:

FTGLBitmapFont FTGLBitmapFont FTGLExtrdFont FTGLExtrdFont FTGLOutlineFont FTGLOutlineFont FTGLPixmapFont FTGLPixmapFont FTGLPolygonFont FTGLPolygonFont FTGLTextureFont FTGLTextureFont List of all members.

Public Member Functions

 FTFont (const char *fontFilePath)
 FTFont (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
virtual ~FTFont ()
bool Attach (const char *fontFilePath)
bool Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
bool CharMap (FT_Encoding encoding)
unsigned int CharMapCount ()
FT_EncodingCharMapList ()
virtual bool FaceSize (const unsigned int size, const unsigned int res=72)
unsigned int FaceSize () const
virtual void Depth (float)
void UseDisplayList (bool useList)
float Ascender () const
float Descender () const
float LineHeight () const
void BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
void BBox (const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
float Advance (const wchar_t *string)
float Advance (const char *string)
virtual void PreRender ()
virtual void PostRender ()
virtual void Render (const char *string)
virtual void Render (const char *string, float w_max, float w_fade)
virtual void Render (const wchar_t *string)
FT_Error Error () const
 FTFont (const char *fontFilePath)
 FTFont (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
virtual ~FTFont ()
bool Attach (const char *fontFilePath)
bool Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
bool CharMap (FT_Encoding encoding)
unsigned int CharMapCount ()
FT_EncodingCharMapList ()
virtual bool FaceSize (const unsigned int size, const unsigned int res=72)
unsigned int FaceSize () const
virtual void Depth (float)
void UseDisplayList (bool useList)
float Ascender () const
float Descender () const
float LineHeight () const
void BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
void BBox (const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
float Advance (const wchar_t *string)
float Advance (const char *string)
virtual void PreRender ()
virtual void PostRender ()
virtual void Render (const char *string)
virtual void Render (const char *string, float w_max, float w_fade)
virtual void Render (const wchar_t *string)
FT_Error Error () const

Protected Member Functions

virtual FTGlyphMakeGlyph (unsigned int g)=0
virtual FTGlyphMakeGlyph (unsigned int g)=0

Protected Attributes

FTFace face
FTSize charSize
bool useDisplayLists
FT_Error err

Private Member Functions

bool CheckGlyph (const unsigned int chr)
bool CheckGlyph (const unsigned int chr)

Private Attributes

bool preRenderCalled
FTGlyphContainerglyphList
FTPoint pen
FTGlyphContainerglyphList

Detailed Description

FTFont is the public interface for the FTGL library.

Specific font classes are derived from this class. It uses the helper classes FTFace and FTSize to access the Freetype library. This class is abstract and deriving classes must implement the protected MakeGlyph function to create glyphs of the appropriate type.

It is good practice after using these functions to test the error code returned. FT_Error Error(). Check the freetype file fterrdef.h for error definitions.

See also:
FTFace

FTSize

FTGlyphContainer

FTGlyph

Definition at line 32 of file FTFont.h.


Constructor & Destructor Documentation

FTFont::FTFont ( const char *  fontFilePath  ) 

Open and read a font file. Sets Error flag.

Parameters:
fontFilePath font file path.

Definition at line 7 of file FTFont.cxx.

References err, FTFace::Error(), face, and glyphList.

FTFont::FTFont ( const unsigned char *  pBufferBytes,
size_t  bufferSizeInBytes 
)

Open and read a font from a buffer in memory. Sets Error flag. The buffer is owned by the client and is NOT copied by FTGL. The pointer must be valid while using FTGL.

Parameters:
pBufferBytes the in-memory buffer
bufferSizeInBytes the length of the buffer in bytes

Definition at line 21 of file FTFont.cxx.

References err, FTFace::Error(), face, and glyphList.

FTFont::~FTFont (  )  [virtual]

Destructor

Definition at line 33 of file FTFont.cxx.

References glyphList.

FTFont::FTFont ( const char *  fontFilePath  ) 

Open and read a font file. Sets Error flag.

Parameters:
fontFilePath font file path.

FTFont::FTFont ( const unsigned char *  pBufferBytes,
size_t  bufferSizeInBytes 
)

Open and read a font from a buffer in memory. Sets Error flag. The buffer is owned by the client and is NOT copied by FTGL. The pointer must be valid while using FTGL.

Parameters:
pBufferBytes the in-memory buffer
bufferSizeInBytes the length of the buffer in bytes

virtual FTFont::~FTFont (  )  [virtual]

Destructor


Member Function Documentation

bool FTFont::Attach ( const char *  fontFilePath  ) 

Attach auxilliary file to font e.g font metrics.

Note: not all font formats implement this function.

Parameters:
fontFilePath auxilliary font file path.
Returns:
true if file has been attached successfully.

Definition at line 39 of file FTFont.cxx.

References FTFace::Attach(), err, FTFace::Error(), and face.

bool FTFont::Attach ( const unsigned char *  pBufferBytes,
size_t  bufferSizeInBytes 
)

Attach auxilliary data to font e.g font metrics, from memory

Note: not all font formats implement this function.

Parameters:
pBufferBytes the in-memory buffer
bufferSizeInBytes the length of the buffer in bytes
Returns:
true if file has been attached successfully.

Definition at line 54 of file FTFont.cxx.

References FTFace::Attach(), err, FTFace::Error(), and face.

bool FTFont::CharMap ( FT_Encoding  encoding  ) 

Set the character map for the face.

Parameters:
encoding Freetype enumerate for char map code.
Returns:
true if charmap was valid and set correctly

Definition at line 95 of file FTFont.cxx.

References FTGlyphContainer::CharMap(), err, FTGlyphContainer::Error(), glyphList, and result().

unsigned int FTFont::CharMapCount (  ) 

Get the number of character maps in this face.

Returns:
character map count.

Definition at line 103 of file FTFont.cxx.

References FTFace::CharMapCount(), and face.

FT_Encoding * FTFont::CharMapList (  ) 

Get a list of character maps in this face.

Returns:
pointer to the first encoding.

Definition at line 109 of file FTFont.cxx.

References FTFace::CharMapList(), and face.

bool FTFont::FaceSize ( const unsigned int  size,
const unsigned int  res = 72 
) [virtual]

Set the char size for the current face.

Parameters:
size the face size in points (1/72 inch)
res the resolution of the target device.
Returns:
true if size was set correctly

Definition at line 69 of file FTFont.cxx.

References charSize, err, FTFace::Error(), face, glyphList, NULL, and FTFace::Size().

Referenced by TGLFontManager::RegisterFont(), and TGLText::SetGLTextFont().

unsigned int FTFont::FaceSize (  )  const

Get the current face size in points.

Returns:
face size

Definition at line 89 of file FTFont.cxx.

References FTSize::CharSize(), and charSize.

Referenced by FTGLTextureFont::FaceSize().

virtual void FTFont::Depth ( float   )  [inline, virtual]

Set the extrusion distance for the font. Only implemented by FTGLExtrdFont

Parameters:
depth The extrusion distance.

Definition at line 125 of file FTFont.h.

Referenced by TGLFontManager::RegisterFont().

void FTFont::UseDisplayList ( bool  useList  ) 

Enable or disable the use of Display Lists inside FTGL

Parameters:
useList true turns ON display lists. false turns OFF display lists.

Definition at line 115 of file FTFont.cxx.

References useDisplayLists.

float FTFont::Ascender (  )  const

Get the global ascender height for the face.

Returns:
Ascender height

Definition at line 120 of file FTFont.cxx.

References FTSize::Ascender(), and charSize.

Referenced by TGLFont::GetAscent().

float FTFont::Descender (  )  const

Gets the global descender height for the face.

Returns:
Descender height

Definition at line 126 of file FTFont.cxx.

References charSize, and FTSize::Descender().

Referenced by TGLFont::GetDescent().

float FTFont::LineHeight (  )  const

Gets the line spacing for the font.

Returns:
Line height

Definition at line 131 of file FTFont.cxx.

References charSize, and FTSize::Height().

Referenced by TGLFont::GetLineHeight().

void FTFont::BBox ( const char *  string,
float &  llx,
float &  lly,
float &  llz,
float &  urx,
float &  ury,
float &  urz 
)

Get the bounding box for a string.

Parameters:
string a char string
llx lower left near x coord
lly lower left near y coord
llz lower left near z coord
urx upper right far x coord
ury upper right far y coord
urz upper right far z coord

Definition at line 136 of file FTFont.cxx.

References FTGlyphContainer::Advance(), FTGlyphContainer::BBox(), c, CheckGlyph(), glyphList, FTBBox::lowerX, FTBBox::lowerY, FTBBox::lowerZ, FTBBox::Move(), NULL, FTBBox::upperX, FTBBox::upperY, and FTBBox::upperZ.

Referenced by TGLText::BBox(), TGLText::PaintBBox(), and TGLText::PaintGLText().

void FTFont::BBox ( const wchar_t *  string,
float &  llx,
float &  lly,
float &  llz,
float &  urx,
float &  ury,
float &  urz 
)

Get the bounding box for a string.

Parameters:
string a wchar_t string
llx lower left near x coord
lly lower left near y coord
llz lower left near z coord
urx upper right far x coord
ury upper right far y coord
urz upper right far z coord

Definition at line 173 of file FTFont.cxx.

References FTGlyphContainer::Advance(), FTGlyphContainer::BBox(), c, CheckGlyph(), glyphList, FTBBox::lowerX, FTBBox::lowerY, FTBBox::lowerZ, FTBBox::Move(), NULL, FTBBox::upperX, FTBBox::upperY, and FTBBox::upperZ.

float FTFont::Advance ( const wchar_t *  string  ) 

Get the advance width for a string.

Parameters:
string a wchar_t string
Returns:
advance width

Definition at line 210 of file FTFont.cxx.

References FTGlyphContainer::Advance(), c, CheckGlyph(), glyphList, and width.

float FTFont::Advance ( const char *  string  ) 

Get the advance width for a string.

Parameters:
string a char string
Returns:
advance width

Definition at line 228 of file FTFont.cxx.

References FTGlyphContainer::Advance(), c, CheckGlyph(), glyphList, and width.

virtual void FTFont::PreRender (  )  [inline, virtual]

Prepare for rendering

Definition at line 201 of file FTFont.h.

Referenced by FTGLOutlineFont::PreRender(), FTGLTextureFont::PreRender(), FTGLPixmapFont::PreRender(), FTGLBitmapFont::PreRender(), and Render().

virtual void FTFont::PostRender (  )  [inline, virtual]

Cleanup after rendering

Definition at line 206 of file FTFont.h.

Referenced by FTGLBitmapFont::PostRender(), FTGLTextureFont::PostRender(), FTGLOutlineFont::PostRender(), FTGLPixmapFont::PostRender(), and Render().

void FTFont::Render ( const char *  string  )  [virtual]

Render a string of characters

Parameters:
string 'C' style string to be output.

Definition at line 246 of file FTFont.cxx.

References c, CheckGlyph(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().

Referenced by TGLText::PaintGLText().

void FTFont::Render ( const char *  string,
float  w_max,
float  w_fade 
) [virtual]

Render a string of characters

Parameters:
string 'C' style string to be output.
w_max maximum width of text
w_fade width at which text starts to fade

Definition at line 267 of file FTFont.cxx.

References c, CheckGlyph(), GL_CURRENT_COLOR, glColor4fv(), glGetFloatv(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), w, FTPoint::X(), and FTPoint::Y().

void FTFont::Render ( const wchar_t *  string  )  [virtual]

Render a string of characters

Parameters:
string wchar_t string to be output.

Definition at line 301 of file FTFont.cxx.

References c, CheckGlyph(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().

FT_Error FTFont::Error (  )  const [inline]

Queries the Font for errors.

Returns:
The current error code.

Definition at line 236 of file FTFont.h.

virtual FTGlyph* FTFont::MakeGlyph ( unsigned int  g  )  [protected, pure virtual]

Construct a glyph of the correct type.

Clients must overide the function and return their specialised FTGlyph.

Parameters:
g The glyph index NOT the char code.
Returns:
An FT****Glyph or null on failure.

Referenced by CheckGlyph().

bool FTFont::CheckGlyph ( const unsigned int  chr  )  [inline, private]

Check that the glyph at chr exist. If not load it.

Parameters:
chr character index
Returns:
true if the glyph can be created.

Definition at line 322 of file FTFont.cxx.

References FTGlyphContainer::Add(), err, FTGlyphContainer::FontIndex(), FTGlyphContainer::Glyph(), glyphList, MakeGlyph(), and NULL.

Referenced by Advance(), BBox(), and Render().

bool FTFont::Attach ( const char *  fontFilePath  ) 

Attach auxilliary file to font e.g font metrics.

Note: not all font formats implement this function.

Parameters:
fontFilePath auxilliary font file path.
Returns:
true if file has been attached successfully.

bool FTFont::Attach ( const unsigned char *  pBufferBytes,
size_t  bufferSizeInBytes 
)

Attach auxilliary data to font e.g font metrics, from memory

Note: not all font formats implement this function.

Parameters:
pBufferBytes the in-memory buffer
bufferSizeInBytes the length of the buffer in bytes
Returns:
true if file has been attached successfully.

bool FTFont::CharMap ( FT_Encoding  encoding  ) 

Set the character map for the face.

Parameters:
encoding Freetype enumerate for char map code.
Returns:
true if charmap was valid and set correctly

unsigned int FTFont::CharMapCount (  ) 

Get the number of character maps in this face.

Returns:
character map count.

FT_Encoding* FTFont::CharMapList (  ) 

Get a list of character maps in this face.

Returns:
pointer to the first encoding.

virtual bool FTFont::FaceSize ( const unsigned int  size,
const unsigned int  res = 72 
) [virtual]

Set the char size for the current face.

Parameters:
size the face size in points (1/72 inch)
res the resolution of the target device.
Returns:
true if size was set correctly

unsigned int FTFont::FaceSize (  )  const

Get the current face size in points.

Returns:
face size

virtual void FTFont::Depth ( float   )  [inline, virtual]

Set the extrusion distance for the font. Only implemented by FTGLExtrdFont

Parameters:
depth The extrusion distance.

Definition at line 125 of file FTFont.h.

void FTFont::UseDisplayList ( bool  useList  ) 

Enable or disable the use of Display Lists inside FTGL

Parameters:
useList true turns ON display lists. false turns OFF display lists.

float FTFont::Ascender (  )  const

Get the global ascender height for the face.

Returns:
Ascender height

float FTFont::Descender (  )  const

Gets the global descender height for the face.

Returns:
Descender height

float FTFont::LineHeight (  )  const

Gets the line spacing for the font.

Returns:
Line height

void FTFont::BBox ( const char *  string,
float &  llx,
float &  lly,
float &  llz,
float &  urx,
float &  ury,
float &  urz 
)

Get the bounding box for a string.

Parameters:
string a char string
llx lower left near x coord
lly lower left near y coord
llz lower left near z coord
urx upper right far x coord
ury upper right far y coord
urz upper right far z coord

void FTFont::BBox ( const wchar_t *  string,
float &  llx,
float &  lly,
float &  llz,
float &  urx,
float &  ury,
float &  urz 
)

Get the bounding box for a string.

Parameters:
string a wchar_t string
llx lower left near x coord
lly lower left near y coord
llz lower left near z coord
urx upper right far x coord
ury upper right far y coord
urz upper right far z coord

float FTFont::Advance ( const wchar_t *  string  ) 

Get the advance width for a string.

Parameters:
string a wchar_t string
Returns:
advance width

float FTFont::Advance ( const char *  string  ) 

Get the advance width for a string.

Parameters:
string a char string
Returns:
advance width

virtual void FTFont::PreRender (  )  [inline, virtual]

Prepare for rendering

Definition at line 201 of file FTFont.h.

virtual void FTFont::PostRender (  )  [inline, virtual]

Cleanup after rendering

Definition at line 206 of file FTFont.h.

virtual void FTFont::Render ( const char *  string  )  [virtual]

Render a string of characters

Parameters:
string 'C' style string to be output.

virtual void FTFont::Render ( const char *  string,
float  w_max,
float  w_fade 
) [virtual]

Render a string of characters

Parameters:
string 'C' style string to be output.
w_max maximum width of text
w_fade width at which text starts to fade

virtual void FTFont::Render ( const wchar_t *  string  )  [virtual]

Render a string of characters

Parameters:
string wchar_t string to be output.

FT_Error FTFont::Error (  )  const [inline]

Queries the Font for errors.

Returns:
The current error code.

Definition at line 236 of file FTFont.h.

virtual FTGlyph* FTFont::MakeGlyph ( unsigned int  g  )  [protected, pure virtual]

Construct a glyph of the correct type.

Clients must overide the function and return their specialised FTGlyph.

Parameters:
g The glyph index NOT the char code.
Returns:
An FT****Glyph or null on failure.

bool FTFont::CheckGlyph ( const unsigned int  chr  )  [inline, private]

Check that the glyph at chr exist. If not load it.

Parameters:
chr character index
Returns:
true if the glyph can be created.


Member Data Documentation

FTFace FTFont::face [protected]

Current face object

Definition at line 253 of file FTFont.h.

Referenced by Attach(), CharMapCount(), CharMapList(), FTGLTextureFont::FaceSize(), FaceSize(), FTFont(), FTGLTextureFont::FTGLTextureFont(), FTGLBitmapFont::MakeGlyph(), FTGLPixmapFont::MakeGlyph(), FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLTextureFont::MakeGlyph(), and FTGLOutlineFont::MakeGlyph().

FTSize FTFont::charSize [protected]

Current size object

Definition at line 258 of file FTFont.h.

Referenced by Ascender(), Descender(), FaceSize(), LineHeight(), and FTGLTextureFont::MakeGlyph().

bool FTFont::useDisplayLists [protected]

Flag to enable or disable the use of Display Lists inside FTGL true turns ON display lists. false turns OFF display lists.

Definition at line 265 of file FTFont.h.

Referenced by FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLOutlineFont::MakeGlyph(), and UseDisplayList().

FT_Error FTFont::err [protected]

Current error code. Zero means no error.

Definition at line 270 of file FTFont.h.

Referenced by Attach(), CharMap(), CheckGlyph(), FaceSize(), FTFont(), FTGLBitmapFont::MakeGlyph(), FTGLPixmapFont::MakeGlyph(), FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLTextureFont::MakeGlyph(), and FTGLOutlineFont::MakeGlyph().

bool FTFont::preRenderCalled [private]

PreRender() was called from outside. Do not call it again from Render(), nor call PostRender(). User has to call it himself.

Definition at line 286 of file FTFont.h.

Referenced by Render().

FTGlyphContainer* FTFont::glyphList [private]

An object that holds a list of glyphs

Definition at line 291 of file FTFont.h.

Referenced by Advance(), BBox(), CharMap(), CheckGlyph(), FaceSize(), FTFont(), Render(), and ~FTFont().

FTPoint FTFont::pen [private]

Current pen or cursor position;

Definition at line 296 of file FTFont.h.

Referenced by Render().

FTGlyphContainer* FTFont::glyphList [private]

An object that holds a list of glyphs

Definition at line 291 of file FTFont.h.


The documentation for this class was generated from the following files:
Generated on Tue Jul 5 16:25:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1