Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

FTFont Class Reference

#include <FTFont.h>

Inheritance diagram for FTFont:

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

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()

See also:
FTFace

FTSize

FTGlyphContainer

FTGlyph

Definition at line 31 of file FTFont.h.

Public Member Functions

 FTFont (const char *fontname)
 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 *filename)
 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 d)
 Set the extrusion distance for the font.

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

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

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.

FT_Error err
 Current error code.


Constructor & Destructor Documentation

FTFont::FTFont const char *  fontname  ) 
 

Open and read a font file.

Sets Error flag.

Parameters:
fontname font file name.

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

References FTFace::Error(), and face.

FTFont::~FTFont  )  [virtual]
 

Destructor.

Definition at line 31 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 210 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 194 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 112 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 52 of file FTFont.cpp.

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

bool FTFont::Attach const char *  filename  ) 
 

Attach auxilliary file to font e.g font metrics.

Note: not all font formats implement this function.

Parameters:
filename auxilliary font file name.
Returns:
true if file has been attached successfully.

Definition at line 37 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 159 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 124 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 92 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 100 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 106 of file FTFont.cpp.

References FTFace::CharMapList(), and face.

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

Set the extrusion distance for the font.

Only implemented by FTGLExtrdFont

Parameters:
d The extrusion distance.

Reimplemented in FTGLExtrdFont.

Definition at line 124 of file FTFont.h.

float FTFont::Descender  )  const
 

Gets the global descender height for the face.

Returns:
Descender height

Definition at line 118 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 201 of file FTFont.h.

unsigned int FTFont::FaceSize  )  const
 

Get the current face size in points.

Returns:
face size

Definition at line 86 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 67 of file FTFont.cpp.

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

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, FTGLBufferFont, FTGLOutlineFont, FTGLPixmapFont, and FTGLTextureFont.

Definition at line 239 of file FTFont.cpp.

References 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, FTGLBufferFont, FTGLOutlineFont, FTGLPixmapFont, and FTGLTextureFont.

Definition at line 226 of file FTFont.cpp.

References FTPoint::x, and FTPoint::y.

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


Member Data Documentation

FTSize FTFont::charSize [protected]
 

Current size object.

Definition at line 223 of file FTFont.h.

FT_Error FTFont::err [protected]
 

Current error code.

Zero means no error.

Definition at line 228 of file FTFont.h.

FTFace FTFont::face [protected]
 

Current face object.

Definition at line 218 of file FTFont.h.

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


The documentation for this class was generated from the following files:
Generated on Mon Aug 16 18:47:20 2004 for FTGL by doxygen 1.3.6