FTFont Class Reference

#include <FTFont.h>

Inheritance diagram for FTFont:

FTBitmapFont FTBufferFont FTExtrudeFont FTOutlineFont FTPixmapFont FTPolygonFont FTTextureFont

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

Definition at line 56 of file FTFont.h.


Public Member Functions

virtual ~FTFont ()
virtual bool Attach (const char *fontFilePath)
 Attach auxilliary file to font e.g font metrics.
virtual bool Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
 Attach auxilliary data to font e.g font metrics, from memory.
virtual void GlyphLoadFlags (FT_Int flags)
 Set the glyph loading flags.
virtual bool CharMap (FT_Encoding encoding)
 Set the character map for the face.
virtual unsigned int CharMapCount () const
 Get the number of character maps in this face.
virtual 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.
virtual unsigned int FaceSize () const
 Get the current face size in points (1/72 inch).
virtual void Depth (float depth)
 Set the extrusion distance for the font.
virtual void Outset (float outset)
 Set the outset distance for the font.
virtual void Outset (float front, float back)
 Set the front and back outset distances for the font.
virtual void UseDisplayList (bool useList)
 Enable or disable the use of Display Lists inside FTGL.
virtual float Ascender () const
 Get the global ascender height for the face.
virtual float Descender () const
 Gets the global descender height for the face.
virtual float LineHeight () const
 Gets the line spacing for the font.
virtual FTBBox BBox (const char *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint())
 Get the bounding box for a string.
void BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
 Get the bounding box for a string (deprecated).
virtual FTBBox BBox (const wchar_t *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint())
 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 (deprecated).
virtual float Advance (const char *string, const int len=-1, FTPoint spacing=FTPoint())
 Get the advance for a string.
virtual float Advance (const wchar_t *string, const int len=-1, FTPoint spacing=FTPoint())
 Get the advance for a string.
virtual FTPoint Render (const char *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint(), int renderMode=FTGL::RENDER_ALL)
 Render a string of characters.
virtual FTPoint Render (const wchar_t *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint(), int renderMode=FTGL::RENDER_ALL)
 Render a string of characters.
virtual FT_Error Error () const
 Queries the Font for errors.

Protected Member Functions

 FTFont (char const *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 FTGlyphMakeGlyph (FT_GlyphSlot slot)=0
 Construct a glyph of the correct type.

Friends

class FTBitmapFont
class FTBufferFont
class FTExtrudeFont
class FTOutlineFont
class FTPixmapFont
class FTPolygonFont
class FTTextureFont
class FTFontImpl

Constructor & Destructor Documentation

FTFont::FTFont ( char const *  fontFilePath  )  [protected]

Open and read a font file.

Sets Error flag.

Parameters:
fontFilePath font file path.

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

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]


Member Function Documentation

virtual bool FTFont::Attach ( const char *  fontFilePath  )  [virtual]

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.

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

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.

virtual void FTFont::GlyphLoadFlags ( FT_Int  flags  )  [virtual]

Set the glyph loading flags.

By default, fonts use the most sensible flags when loading a font's glyph using FT_Load_Glyph(). This function allows to override the default flags.

Parameters:
flags The glyph loading flags.

virtual bool FTFont::CharMap ( FT_Encoding  encoding  )  [virtual]

Set the character map for the face.

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

virtual unsigned int FTFont::CharMapCount (  )  const [virtual]

Get the number of character maps in this face.

Returns:
character map count.

virtual FT_Encoding* FTFont::CharMapList (  )  [virtual]

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

virtual unsigned int FTFont::FaceSize (  )  const [virtual]

Get the current face size in points (1/72 inch).

Returns:
face size

virtual void FTFont::Depth ( float  depth  )  [virtual]

Set the extrusion distance for the font.

Only implemented by FTExtrudeFont

Parameters:
depth The extrusion distance.

virtual void FTFont::Outset ( float  outset  )  [virtual]

Set the outset distance for the font.

Only implemented by FTOutlineFont, FTPolygonFont and FTExtrudeFont

Parameters:
outset The outset distance.

virtual void FTFont::Outset ( float  front,
float  back 
) [virtual]

Set the front and back outset distances for the font.

Only implemented by FTExtrudeFont

Parameters:
front The front outset distance.
back The back outset distance.

virtual void FTFont::UseDisplayList ( bool  useList  )  [virtual]

Enable or disable the use of Display Lists inside FTGL.

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

virtual float FTFont::Ascender (  )  const [virtual]

Get the global ascender height for the face.

Returns:
Ascender height

virtual float FTFont::Descender (  )  const [virtual]

Gets the global descender height for the face.

Returns:
Descender height

virtual float FTFont::LineHeight (  )  const [virtual]

Gets the line spacing for the font.

Returns:
Line height

virtual FTBBox FTFont::BBox ( const char *  string,
const int  len = -1,
FTPoint  position = FTPoint(),
FTPoint  spacing = FTPoint() 
) [virtual]

Get the bounding box for a string.

Parameters:
string A char buffer.
len The length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
position The pen position of the first character (optional).
spacing A displacement vector to add after each character has been checked (optional).
Returns:
The corresponding bounding box.

Referenced by BBox().

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

Get the bounding box for a string (deprecated).

Parameters:
string A char buffer.
llx Lower left near x coordinate.
lly Lower left near y coordinate.
llz Lower left near z coordinate.
urx Upper right far x coordinate.
ury Upper right far y coordinate.
urz Upper right far z coordinate.

Definition at line 251 of file FTFont.h.

References BBox(), FTBBox::Lower(), FTBBox::Upper(), FTPoint::Xf(), FTPoint::Yf(), and FTPoint::Zf().

virtual FTBBox FTFont::BBox ( const wchar_t *  string,
const int  len = -1,
FTPoint  position = FTPoint(),
FTPoint  spacing = FTPoint() 
) [virtual]

Get the bounding box for a string.

Parameters:
string A wchar_t buffer.
len The length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
position The pen position of the first character (optional).
spacing A displacement vector to add after each character has been checked (optional).
Returns:
The corresponding bounding box.

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

Get the bounding box for a string (deprecated).

Parameters:
string A wchar_t buffer.
llx Lower left near x coordinate.
lly Lower left near y coordinate.
llz Lower left near z coordinate.
urx Upper right far x coordinate.
ury Upper right far y coordinate.
urz Upper right far z coordinate.

Definition at line 286 of file FTFont.h.

References BBox(), FTBBox::Lower(), FTBBox::Upper(), FTPoint::Xf(), FTPoint::Yf(), and FTPoint::Zf().

virtual float FTFont::Advance ( const char *  string,
const int  len = -1,
FTPoint  spacing = FTPoint() 
) [virtual]

Get the advance for a string.

Parameters:
string 'C' style string to be checked.
len The length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
spacing A displacement vector to add after each character has been checked (optional).
Returns:
The string's advance width.

virtual float FTFont::Advance ( const wchar_t *  string,
const int  len = -1,
FTPoint  spacing = FTPoint() 
) [virtual]

Get the advance for a string.

Parameters:
string A wchar_t string
len The length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
spacing A displacement vector to add after each character has been checked (optional).
Returns:
The string's advance width.

virtual FTPoint FTFont::Render ( const char *  string,
const int  len = -1,
FTPoint  position = FTPoint(),
FTPoint  spacing = FTPoint(),
int  renderMode = FTGL::RENDER_ALL 
) [virtual]

Render a string of characters.

Parameters:
string 'C' style string to be output.
len The length of the string. If < 0 then all characters will be displayed until a null character is encountered (optional).
position The pen position of the first character (optional).
spacing A displacement vector to add after each character has been displayed (optional).
renderMode Render mode to use for display (optional).
Returns:
The new pen position after the last character was output.

virtual FTPoint FTFont::Render ( const wchar_t *  string,
const int  len = -1,
FTPoint  position = FTPoint(),
FTPoint  spacing = FTPoint(),
int  renderMode = FTGL::RENDER_ALL 
) [virtual]

Render a string of characters.

Parameters:
string wchar_t string to be output.
len The length of the string. If < 0 then all characters will be displayed until a null character is encountered (optional).
position The pen position of the first character (optional).
spacing A displacement vector to add after each character has been displayed (optional).
renderMode Render mode to use for display (optional).
Returns:
The new pen position after the last character was output.

virtual FT_Error FTFont::Error (  )  const [virtual]

Queries the Font for errors.

Returns:
The current error code.

virtual FTGlyph* FTFont::MakeGlyph ( FT_GlyphSlot  slot  )  [protected, pure virtual]

Construct a glyph of the correct type.

Clients must override the function and return their specialised FTGlyph.

Parameters:
slot A FreeType glyph slot.
Returns:
An FT****Glyph or null on failure.

Implemented in FTBufferFont, FTBitmapFont, FTExtrudeFont, FTOutlineFont, FTPixmapFont, FTPolygonFont, and FTTextureFont.


Friends And Related Function Documentation

friend class FTBitmapFont [friend]

Definition at line 78 of file FTFont.h.

friend class FTBufferFont [friend]

Definition at line 79 of file FTFont.h.

friend class FTExtrudeFont [friend]

Definition at line 80 of file FTFont.h.

friend class FTOutlineFont [friend]

Definition at line 81 of file FTFont.h.

friend class FTPixmapFont [friend]

Definition at line 82 of file FTFont.h.

friend class FTPolygonFont [friend]

Definition at line 83 of file FTFont.h.

friend class FTTextureFont [friend]

Definition at line 84 of file FTFont.h.

friend class FTFontImpl [friend]

Definition at line 367 of file FTFont.h.


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

Generated on Thu Jun 12 14:45:03 2008 for FTGL by  doxygen 1.5.6