#include <FTFont.h>
Inheritance diagram for FTFont:
Public Member Functions | |
FTFont (const char *fontFilePath) | |
FTFont (const unsigned char *pBufferBytes, size_t bufferSizeInBytes) | |
virtual | ~FTFont () |
bool | Attach (const char *fontFilePath) |
bool | Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes) |
bool | CharMap (FT_Encoding encoding) |
unsigned int | CharMapCount () |
FT_Encoding * | CharMapList () |
virtual bool | FaceSize (const unsigned int size, const unsigned int res=72) |
unsigned int | FaceSize () const |
virtual void | Depth (float) |
void | UseDisplayList (bool useList) |
float | Ascender () const |
float | Descender () const |
float | LineHeight () const |
void | BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz) |
void | BBox (const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz) |
float | Advance (const wchar_t *string) |
float | Advance (const char *string) |
virtual void | PreRender () |
virtual void | PostRender () |
virtual void | Render (const char *string) |
virtual void | Render (const char *string, float w_max, float w_fade) |
virtual void | Render (const wchar_t *string) |
FT_Error | Error () const |
FTFont (const char *fontFilePath) | |
FTFont (const unsigned char *pBufferBytes, size_t bufferSizeInBytes) | |
virtual | ~FTFont () |
bool | Attach (const char *fontFilePath) |
bool | Attach (const unsigned char *pBufferBytes, size_t bufferSizeInBytes) |
bool | CharMap (FT_Encoding encoding) |
unsigned int | CharMapCount () |
FT_Encoding * | CharMapList () |
virtual bool | FaceSize (const unsigned int size, const unsigned int res=72) |
unsigned int | FaceSize () const |
virtual void | Depth (float) |
void | UseDisplayList (bool useList) |
float | Ascender () const |
float | Descender () const |
float | LineHeight () const |
void | BBox (const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz) |
void | BBox (const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz) |
float | Advance (const wchar_t *string) |
float | Advance (const char *string) |
virtual void | PreRender () |
virtual void | PostRender () |
virtual void | Render (const char *string) |
virtual void | Render (const char *string, float w_max, float w_fade) |
virtual void | Render (const wchar_t *string) |
FT_Error | Error () const |
Protected Member Functions | |
virtual FTGlyph * | MakeGlyph (unsigned int g)=0 |
virtual FTGlyph * | MakeGlyph (unsigned int g)=0 |
Protected Attributes | |
FTFace | face |
FTSize | charSize |
bool | useDisplayLists |
FT_Error | err |
Private Member Functions | |
bool | CheckGlyph (const unsigned int chr) |
bool | CheckGlyph (const unsigned int chr) |
Private Attributes | |
bool | preRenderCalled |
FTGlyphContainer * | glyphList |
FTPoint | pen |
FTGlyphContainer * | glyphList |
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.
Definition at line 32 of file FTFont.h.
FTFont::FTFont | ( | const char * | fontFilePath | ) |
Open and read a font file. Sets Error flag.
fontFilePath | font file path. |
Definition at line 7 of file FTFont.cxx.
References err, FTFace::Error(), face, and glyphList.
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.
pBufferBytes | the in-memory buffer | |
bufferSizeInBytes | the length of the buffer in bytes |
Definition at line 21 of file FTFont.cxx.
References err, FTFace::Error(), face, and glyphList.
FTFont::~FTFont | ( | ) | [virtual] |
FTFont::FTFont | ( | const char * | fontFilePath | ) |
Open and read a font file. Sets Error flag.
fontFilePath | font file path. |
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.
pBufferBytes | the in-memory buffer | |
bufferSizeInBytes | the length of the buffer in bytes |
virtual FTFont::~FTFont | ( | ) | [virtual] |
Destructor
bool FTFont::Attach | ( | const char * | fontFilePath | ) |
Attach auxilliary file to font e.g font metrics.
Note: not all font formats implement this function.
fontFilePath | auxilliary font file path. |
true
if file has been attached successfully. Definition at line 39 of file FTFont.cxx.
References FTFace::Attach(), err, FTFace::Error(), and face.
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.
pBufferBytes | the in-memory buffer | |
bufferSizeInBytes | the length of the buffer in bytes |
true
if file has been attached successfully. Definition at line 54 of file FTFont.cxx.
References FTFace::Attach(), err, FTFace::Error(), and face.
bool FTFont::CharMap | ( | FT_Encoding | encoding | ) |
Set the character map for the face.
encoding | Freetype enumerate for char map code. |
true
if charmap was valid and set correctly Definition at line 95 of file FTFont.cxx.
References FTGlyphContainer::CharMap(), err, FTGlyphContainer::Error(), glyphList, and result().
unsigned int FTFont::CharMapCount | ( | ) |
Get the number of character maps in this face.
Definition at line 103 of file FTFont.cxx.
References FTFace::CharMapCount(), and face.
FT_Encoding * FTFont::CharMapList | ( | ) |
Get a list of character maps in this face.
Definition at line 109 of file FTFont.cxx.
References FTFace::CharMapList(), and face.
bool FTFont::FaceSize | ( | const unsigned int | size, | |
const unsigned int | res = 72 | |||
) | [virtual] |
Set the char size for the current face.
size | the face size in points (1/72 inch) | |
res | the resolution of the target device. |
true
if size was set correctly Definition at line 69 of file FTFont.cxx.
References charSize, err, FTFace::Error(), face, glyphList, NULL, and FTFace::Size().
Referenced by TGLFontManager::RegisterFont(), and TGLText::SetGLTextFont().
unsigned int FTFont::FaceSize | ( | ) | const |
Get the current face size in points.
Definition at line 89 of file FTFont.cxx.
References FTSize::CharSize(), and charSize.
Referenced by FTGLTextureFont::FaceSize().
virtual void FTFont::Depth | ( | float | ) | [inline, virtual] |
Set the extrusion distance for the font. Only implemented by FTGLExtrdFont
depth | The extrusion distance. |
Definition at line 125 of file FTFont.h.
Referenced by TGLFontManager::RegisterFont().
void FTFont::UseDisplayList | ( | bool | useList | ) |
Enable or disable the use of Display Lists inside FTGL
useList | true turns ON display lists. false turns OFF display lists. |
Definition at line 115 of file FTFont.cxx.
References useDisplayLists.
float FTFont::Ascender | ( | ) | const |
Get the global ascender height for the face.
Definition at line 120 of file FTFont.cxx.
References FTSize::Ascender(), and charSize.
Referenced by TGLFont::GetAscent().
float FTFont::Descender | ( | ) | const |
Gets the global descender height for the face.
Definition at line 126 of file FTFont.cxx.
References charSize, and FTSize::Descender().
Referenced by TGLFont::GetDescent().
float FTFont::LineHeight | ( | ) | const |
Gets the line spacing for the font.
Definition at line 131 of file FTFont.cxx.
References charSize, and FTSize::Height().
Referenced by TGLFont::GetLineHeight().
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.
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 136 of file FTFont.cxx.
References FTGlyphContainer::Advance(), FTGlyphContainer::BBox(), c, CheckGlyph(), glyphList, FTBBox::lowerX, FTBBox::lowerY, FTBBox::lowerZ, FTBBox::Move(), NULL, FTBBox::upperX, FTBBox::upperY, and FTBBox::upperZ.
Referenced by TGLText::BBox(), TGLText::PaintBBox(), and TGLText::PaintGLText().
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.
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 173 of file FTFont.cxx.
References FTGlyphContainer::Advance(), FTGlyphContainer::BBox(), c, CheckGlyph(), glyphList, FTBBox::lowerX, FTBBox::lowerY, FTBBox::lowerZ, FTBBox::Move(), NULL, FTBBox::upperX, FTBBox::upperY, and FTBBox::upperZ.
float FTFont::Advance | ( | const wchar_t * | string | ) |
Get the advance width for a string.
string | a wchar_t string |
Definition at line 210 of file FTFont.cxx.
References FTGlyphContainer::Advance(), c, CheckGlyph(), glyphList, and width.
float FTFont::Advance | ( | const char * | string | ) |
Get the advance width for a string.
string | a char string |
Definition at line 228 of file FTFont.cxx.
References FTGlyphContainer::Advance(), c, CheckGlyph(), glyphList, and width.
virtual void FTFont::PreRender | ( | ) | [inline, virtual] |
Prepare for rendering
Definition at line 201 of file FTFont.h.
Referenced by FTGLOutlineFont::PreRender(), FTGLTextureFont::PreRender(), FTGLPixmapFont::PreRender(), FTGLBitmapFont::PreRender(), and Render().
virtual void FTFont::PostRender | ( | ) | [inline, virtual] |
Cleanup after rendering
Definition at line 206 of file FTFont.h.
Referenced by FTGLBitmapFont::PostRender(), FTGLTextureFont::PostRender(), FTGLOutlineFont::PostRender(), FTGLPixmapFont::PostRender(), and Render().
void FTFont::Render | ( | const char * | string | ) | [virtual] |
Render a string of characters
string | 'C' style string to be output. |
Definition at line 246 of file FTFont.cxx.
References c, CheckGlyph(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().
Referenced by TGLText::PaintGLText().
void FTFont::Render | ( | const char * | string, | |
float | w_max, | |||
float | w_fade | |||
) | [virtual] |
Render a string of characters
string | 'C' style string to be output. | |
w_max | maximum width of text | |
w_fade | width at which text starts to fade |
Definition at line 267 of file FTFont.cxx.
References c, CheckGlyph(), GL_CURRENT_COLOR, glColor4fv(), glGetFloatv(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), w, FTPoint::X(), and FTPoint::Y().
void FTFont::Render | ( | const wchar_t * | string | ) | [virtual] |
Render a string of characters
string | wchar_t string to be output. |
Definition at line 301 of file FTFont.cxx.
References c, CheckGlyph(), glyphList, pen, PostRender(), PreRender(), preRenderCalled, FTGlyphContainer::Render(), FTPoint::X(), and FTPoint::Y().
FT_Error FTFont::Error | ( | ) | const [inline] |
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.
g | The glyph index NOT the char code. |
null
on failure. Referenced by CheckGlyph().
bool FTFont::CheckGlyph | ( | const unsigned int | chr | ) | [inline, private] |
Check that the glyph at chr
exist. If not load it.
chr | character index |
true
if the glyph can be created. Definition at line 322 of file FTFont.cxx.
References FTGlyphContainer::Add(), err, FTGlyphContainer::FontIndex(), FTGlyphContainer::Glyph(), glyphList, MakeGlyph(), and NULL.
bool FTFont::Attach | ( | const char * | fontFilePath | ) |
Attach auxilliary file to font e.g font metrics.
Note: not all font formats implement this function.
fontFilePath | auxilliary font file path. |
true
if file has been attached successfully. 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.
pBufferBytes | the in-memory buffer | |
bufferSizeInBytes | the length of the buffer in bytes |
true
if file has been attached successfully. bool FTFont::CharMap | ( | FT_Encoding | encoding | ) |
Set the character map for the face.
encoding | Freetype enumerate for char map code. |
true
if charmap was valid and set correctly unsigned int FTFont::CharMapCount | ( | ) |
Get the number of character maps in this face.
FT_Encoding* FTFont::CharMapList | ( | ) |
Get a list of character maps in this face.
virtual bool FTFont::FaceSize | ( | const unsigned int | size, | |
const unsigned int | res = 72 | |||
) | [virtual] |
Set the char size for the current face.
size | the face size in points (1/72 inch) | |
res | the resolution of the target device. |
true
if size was set correctly unsigned int FTFont::FaceSize | ( | ) | const |
Get the current face size in points.
virtual void FTFont::Depth | ( | float | ) | [inline, virtual] |
Set the extrusion distance for the font. Only implemented by FTGLExtrdFont
depth | The extrusion distance. |
void FTFont::UseDisplayList | ( | bool | useList | ) |
Enable or disable the use of Display Lists inside FTGL
useList | true turns ON display lists. false turns OFF display lists. |
float FTFont::Ascender | ( | ) | const |
Get the global ascender height for the face.
float FTFont::Descender | ( | ) | const |
Gets the global descender height for the face.
float FTFont::LineHeight | ( | ) | const |
Gets the line spacing for the font.
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.
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 |
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.
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 |
float FTFont::Advance | ( | const wchar_t * | string | ) |
Get the advance width for a string.
string | a wchar_t string |
float FTFont::Advance | ( | const char * | string | ) |
Get the advance width for a string.
string | a char string |
virtual void FTFont::PreRender | ( | ) | [inline, virtual] |
virtual void FTFont::PostRender | ( | ) | [inline, virtual] |
virtual void FTFont::Render | ( | const char * | string | ) | [virtual] |
Render a string of characters
string | 'C' style string to be output. |
virtual void FTFont::Render | ( | const char * | string, | |
float | w_max, | |||
float | w_fade | |||
) | [virtual] |
Render a string of characters
string | 'C' style string to be output. | |
w_max | maximum width of text | |
w_fade | width at which text starts to fade |
virtual void FTFont::Render | ( | const wchar_t * | string | ) | [virtual] |
Render a string of characters
string | wchar_t string to be output. |
FT_Error FTFont::Error | ( | ) | const [inline] |
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.
g | The glyph index NOT the char code. |
null
on failure. bool FTFont::CheckGlyph | ( | const unsigned int | chr | ) | [inline, private] |
Check that the glyph at chr
exist. If not load it.
chr | character index |
true
if the glyph can be created.
FTFace FTFont::face [protected] |
Current face object
Definition at line 253 of file FTFont.h.
Referenced by Attach(), CharMapCount(), CharMapList(), FTGLTextureFont::FaceSize(), FaceSize(), FTFont(), FTGLTextureFont::FTGLTextureFont(), FTGLBitmapFont::MakeGlyph(), FTGLPixmapFont::MakeGlyph(), FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLTextureFont::MakeGlyph(), and FTGLOutlineFont::MakeGlyph().
FTSize FTFont::charSize [protected] |
Current size object
Definition at line 258 of file FTFont.h.
Referenced by Ascender(), Descender(), FaceSize(), LineHeight(), and FTGLTextureFont::MakeGlyph().
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 265 of file FTFont.h.
Referenced by FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLOutlineFont::MakeGlyph(), and UseDisplayList().
FT_Error FTFont::err [protected] |
Current error code. Zero means no error.
Definition at line 270 of file FTFont.h.
Referenced by Attach(), CharMap(), CheckGlyph(), FaceSize(), FTFont(), FTGLBitmapFont::MakeGlyph(), FTGLPixmapFont::MakeGlyph(), FTGLExtrdFont::MakeGlyph(), FTGLPolygonFont::MakeGlyph(), FTGLTextureFont::MakeGlyph(), and FTGLOutlineFont::MakeGlyph().
bool FTFont::preRenderCalled [private] |
PreRender() was called from outside. Do not call it again from Render(), nor call PostRender(). User has to call it himself.
Definition at line 286 of file FTFont.h.
Referenced by Render().
FTGlyphContainer* FTFont::glyphList [private] |
An object that holds a list of glyphs
Definition at line 291 of file FTFont.h.
Referenced by Advance(), BBox(), CharMap(), CheckGlyph(), FaceSize(), FTFont(), Render(), and ~FTFont().
FTPoint FTFont::pen [private] |
FTGlyphContainer* FTFont::glyphList [private] |