Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FTFont Class Reference

#include <FTFont.h>

Inheritance diagram for FTFont:

FTGLBitmapFont FTGLExtrdFont FTGLOutlineFont FTGLPixmapFont FTGLPolygonFont FTGLTextureFont

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.

Public Member Functions

 FTFont (const char *fontFilePath)
 Open and read a font file.

 FTFont (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
 Open and read a font from a buffer in memory.

virtual ~FTFont ()
 Destructor.

bool Attach (const char *fontFilePath)
 Attach auxilliary file to font e.g font metrics.

bool Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
 Attach auxilliary data to font e.g font metrics, from memory.

bool CharMap (FT_Encoding encoding)
 Set the character map for the face.

unsigned int CharMapCount ()
 Get the number of character maps in this face.

FT_Encoding * CharMapList ()
 Get a list of character maps in this face.

virtual bool FaceSize (const unsigned int size, const unsigned int res=72)
 Set the char size for the current face.

unsigned int FaceSize () const
 Get the current face size in points.

virtual void Depth (float depth)
 Set the extrusion distance for the font.

void UseDisplayList (bool useList)
 Enable or disable the use of Display Lists inside FTGL.

float Ascender () const
 Get the global ascender height for the face.

float Descender () const
 Gets the global descender height for the face.

float LineHeight () const
 Gets the line spacing for the font.

void BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
 Get the bounding box for a string.

void BBox (const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
 Get the bounding box for a string.

float Advance (const wchar_t *string)
 Get the advance width for a string.

float Advance (const char *string)
 Get the advance width for a string.

virtual void Render (const char *string)
 Render a string of characters.

virtual void Render (const wchar_t *string)
 Render a string of characters.

FT_Error Error () const
 Queries the Font for errors.


Protected Member Functions

virtual FTGlyphMakeGlyph (unsigned int g)=0
 Construct a glyph of the correct type.


Protected Attributes

FTFace face
 Current face object.

FTSize charSize
 Current size object.

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

FT_Error err
 Current error code.


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.cpp.

References FTFace::Error(), and face.

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 20 of file FTFont.cpp.

References FTFace::Error(), and face.

FTFont::~FTFont  )  [virtual]
 

Destructor.

Definition at line 32 of file FTFont.cpp.


Member Function Documentation

float FTFont::Advance const char *  string  ) 
 

Get the advance width for a string.

Parameters:
string a char string
Returns:
advance width

Definition at line 227 of file FTFont.cpp.

References FTGlyphContainer::Advance().

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 209 of file FTFont.cpp.

References FTGlyphContainer::Advance().

float FTFont::Ascender  )  const
 

Get the global ascender height for the face.

Returns:
Ascender height

Definition at line 119 of file FTFont.cpp.

References FTSize::Ascender().

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 53 of file FTFont.cpp.

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

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 38 of file FTFont.cpp.

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

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 172 of file FTFont.cpp.

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

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 135 of file FTFont.cpp.

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

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 94 of file FTFont.cpp.

References FTGlyphContainer::CharMap(), and FTGlyphContainer::Error().

unsigned int FTFont::CharMapCount  ) 
 

Get the number of character maps in this face.

Returns:
character map count.

Definition at line 102 of file FTFont.cpp.

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 108 of file FTFont.cpp.

References FTFace::CharMapList(), and face.

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

Set the extrusion distance for the font.

Only implemented by FTGLExtrdFont

Parameters:
depth The extrusion distance.

Reimplemented in FTGLExtrdFont.

Definition at line 125 of file FTFont.h.

float FTFont::Descender  )  const
 

Gets the global descender height for the face.

Returns:
Descender height

Definition at line 125 of file FTFont.cpp.

References FTSize::Descender().

FT_Error FTFont::Error  )  const [inline]
 

Queries the Font for errors.

Returns:
The current error code.

Definition at line 217 of file FTFont.h.

unsigned int FTFont::FaceSize  )  const
 

Get the current face size in points.

Returns:
face size

Definition at line 88 of file FTFont.cpp.

References FTSize::CharSize().

Referenced by FTGLTextureFont::FaceSize().

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

Reimplemented in FTGLTextureFont.

Definition at line 68 of file FTFont.cpp.

References FTFace::Error(), face, and FTFace::Size().

float FTFont::LineHeight  )  const
 

Gets the line spacing for the font.

Returns:
Line height

Definition at line 130 of file FTFont.cpp.

References FTSize::Height().

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.

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

Render a string of characters.

Parameters:
string wchar_t string to be output.

Reimplemented in FTGLBitmapFont, FTGLOutlineFont, FTGLPixmapFont, and FTGLTextureFont.

Definition at line 261 of file FTFont.cpp.

References FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().

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

Render a string of characters.

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

Reimplemented in FTGLBitmapFont, FTGLOutlineFont, FTGLPixmapFont, and FTGLTextureFont.

Definition at line 245 of file FTFont.cpp.

References FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().

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

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 114 of file FTFont.cpp.

References useDisplayLists.


Field Documentation

FTSize FTFont::charSize [protected]
 

Current size object.

Definition at line 239 of file FTFont.h.

FT_Error FTFont::err [protected]
 

Current error code.

Zero means no error.

Definition at line 251 of file FTFont.h.

FTFace FTFont::face [protected]
 

Current face object.

Definition at line 234 of file FTFont.h.

Referenced by Attach(), CharMapCount(), CharMapList(), FaceSize(), and FTFont().

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 246 of file FTFont.h.

Referenced by UseDisplayList().


The documentation for this class was generated from the following files:
Generated on Sun Dec 5 22:24:07 2004 for FTGL by doxygen 1.3.6