FTGL 2.1.3~rc5
Public Member Functions | Protected Member Functions | Friends
FTFont Class Reference

FTFont is the public interface for the FTGL library. More...

#include <FTFont.h>

Inheritance diagram for FTFont:
FTBitmapFont FTBufferFont FTExtrudeFont FTOutlineFont FTPixmapFont FTPolygonFont FTTextureFont

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

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.


Constructor & Destructor Documentation

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

Open and read a font file.

Sets Error flag.

Parameters:
fontFilePathfont 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:
pBufferBytesthe in-memory buffer
bufferSizeInBytesthe length of the buffer in bytes
virtual FTFont::~FTFont ( ) [virtual]

Member Function Documentation

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.
lenThe length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
spacingA 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:
stringA wchar_t string
lenThe length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
spacingA displacement vector to add after each character has been checked (optional).
Returns:
The string's advance width.
virtual float FTFont::Ascender ( ) const [virtual]

Get the global ascender height for the face.

Returns:
Ascender height
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:
pBufferBytesthe in-memory buffer.
bufferSizeInBytesthe length of the buffer in bytes.
Returns:
true if file has been attached successfully.
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:
fontFilePathauxilliary font file path.
Returns:
true if file has been attached successfully.
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:
stringA char buffer.
lenThe length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
positionThe pen position of the first character (optional).
spacingA 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:
stringA char buffer.
llxLower left near x coordinate.
llyLower left near y coordinate.
llzLower left near z coordinate.
urxUpper right far x coordinate.
uryUpper right far y coordinate.
urzUpper 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:
stringA wchar_t buffer.
lenThe length of the string. If < 0 then all characters will be checked until a null character is encountered (optional).
positionThe pen position of the first character (optional).
spacingA 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:
stringA wchar_t buffer.
llxLower left near x coordinate.
llyLower left near y coordinate.
llzLower left near z coordinate.
urxUpper right far x coordinate.
uryUpper right far y coordinate.
urzUpper 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 bool FTFont::CharMap ( FT_Encoding  encoding) [virtual]

Set the character map for the face.

Parameters:
encodingFreetype 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 void FTFont::Depth ( float  depth) [virtual]

Set the extrusion distance for the font.

Only implemented by FTExtrudeFont

Parameters:
depthThe extrusion distance.
virtual float FTFont::Descender ( ) const [virtual]

Gets the global descender height for the face.

Returns:
Descender height
virtual FT_Error FTFont::Error ( ) const [virtual]

Queries the Font for errors.

Returns:
The current error code.
virtual unsigned int FTFont::FaceSize ( ) const [virtual]

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

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

Set the char size for the current face.

Parameters:
sizethe face size in points (1/72 inch)
resthe resolution of the target device.
Returns:
true if size was set correctly
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:
flagsThe glyph loading flags.
virtual float FTFont::LineHeight ( ) const [virtual]

Gets the line spacing for the font.

Returns:
Line height
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:
slotA FreeType glyph slot.
Returns:
An FT****Glyph or null on failure.

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

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

Set the front and back outset distances for the font.

Only implemented by FTExtrudeFont

Parameters:
frontThe front outset distance.
backThe back outset distance.
virtual void FTFont::Outset ( float  outset) [virtual]

Set the outset distance for the font.

Only implemented by FTOutlineFont, FTPolygonFont and FTExtrudeFont

Parameters:
outsetThe outset distance.
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.
lenThe length of the string. If < 0 then all characters will be displayed until a null character is encountered (optional).
positionThe pen position of the first character (optional).
spacingA displacement vector to add after each character has been displayed (optional).
renderModeRender 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:
stringwchar_t string to be output.
lenThe length of the string. If < 0 then all characters will be displayed until a null character is encountered (optional).
positionThe pen position of the first character (optional).
spacingA displacement vector to add after each character has been displayed (optional).
renderModeRender mode to use for display (optional).
Returns:
The new pen position after the last character was output.
virtual void FTFont::UseDisplayList ( bool  useList) [virtual]

Enable or disable the use of Display Lists inside FTGL.

Parameters:
useListtrue turns ON display lists. false turns OFF display lists.

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 FTFontImpl [friend]

Definition at line 367 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.


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