FTFont Class Referenceabstract

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

`#include <FTFont.h>`

Inheritance diagram for FTFont:

## 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 FTGlyph * | MakeGlyph (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 | FTTriangleExtractorFont
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() [1/2]

FTFont::FTFont | ( | char const * | fontFilePath | ) |

protected

Open and read a font file.

Sets Error flag.

Parameters

  fontFilePath | font file path.

## FTFont() [2/2]

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

## ~FTFont()

virtual FTFont::~FTFont | ( |  | ) |

virtual

## Member Function Documentation

## Advance() [1/2]

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.

## Advance() [2/2]

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.

## Ascender()

virtual float FTFont::Ascender | ( |  | ) | const

virtual

Get the global ascender height for the face.

Returns
  Ascender height

## Attach() [1/2]

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.

## Attach() [2/2]

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.

## BBox() [1/4]

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.

## BBox() [2/4]

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

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

## BBox() [3/4]

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.

## BBox() [4/4]

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

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

## CharMap()

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.

## CharMapCount()

virtual unsigned int FTFont::CharMapCount | ( |  | ) | const

virtual

Get the number of character maps in this face.

Returns
  character map count.

## CharMapList()

virtual FT_Encoding * FTFont::CharMapList | ( |  | ) |

virtual

Get a list of character maps in this face.

Returns
  pointer to the first encoding.

## Depth()

virtual void FTFont::Depth | ( | float | depth | ) |

virtual

Set the extrusion distance for the font.

Only implemented by FTExtrudeFont

Parameters

  depth | The extrusion distance.

## Descender()

virtual float FTFont::Descender | ( |  | ) | const

virtual

Gets the global descender height for the face.

Returns
  Descender height

## Error()

virtual FT_Error FTFont::Error | ( |  | ) | const

virtual

Queries the Font for errors.

Returns
  The current error code.

## FaceSize() [1/2]

virtual unsigned int FTFont::FaceSize | ( |  | ) | const

virtual

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

Returns
  face size

## FaceSize() [2/2]

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

## GlyphLoadFlags()

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.

## LineHeight()

virtual float FTFont::LineHeight | ( |  | ) | const

virtual

Gets the line spacing for the font.

Returns
  Line height

## MakeGlyph()

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, FTTextureFont, and FTTriangleExtractorFont.

## Outset() [1/2]

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.

## Outset() [2/2]

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.

## Render() [1/2]

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). Gives the application the ability to control whether to render the font's front and back faces via FTGL::RENDER_FRONT and FTGL::RENDER_BACK respectively, or font sides via FTGL::RENDER_SIDE for extruded glyph fonts.

Returns
  The new pen position after the last character was output.

## Render() [2/2]

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). Gives the application the ability to control whether to render the font's front and back faces via FTGL::RENDER_FRONT and FTGL::RENDER_BACK respectively, or font sides via FTGL::RENDER_SIDE for extruded glyph fonts.

Returns
  The new pen position after the last character was output.

## UseDisplayList()

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.

## Friends And Related Symbol Documentation

## FTBitmapFont

friend class FTBitmapFont

friend

Definition at line 78 of file FTFont.h.

## FTBufferFont

friend class FTBufferFont

friend

Definition at line 79 of file FTFont.h.

## FTExtrudeFont

friend class FTExtrudeFont

friend

Definition at line 80 of file FTFont.h.

## FTFontImpl

friend class FTFontImpl

friend

Definition at line 382 of file FTFont.h.

## FTOutlineFont

friend class FTOutlineFont

friend

Definition at line 81 of file FTFont.h.

## FTPixmapFont

friend class FTPixmapFont

friend

Definition at line 82 of file FTFont.h.

## FTPolygonFont

friend class FTPolygonFont

friend

Definition at line 83 of file FTFont.h.

## FTTextureFont

friend class FTTextureFont

friend

Definition at line 84 of file FTFont.h.

## FTTriangleExtractorFont

friend class FTTriangleExtractorFont

friend

Definition at line 85 of file FTFont.h.

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

- FTFont.h