FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FIFE::TrueTypeFont Class Reference

SDL True Type Font implementation of Font. More...

#include <truetypefont.h>

+ Inheritance diagram for FIFE::TrueTypeFont:
+ Collaboration diagram for FIFE::TrueTypeFont:

Public Member Functions

 TrueTypeFont (const std::string &filename, int32_t size)
 Constructor. More...
 
virtual ~TrueTypeFont ()
 Destructor. More...
 
virtual int32_t getWidth (const std::string &text) const
 gets width of given text More...
 
virtual int32_t getHeight () const
 gets height of this font More...
 
virtual SDL_Surface * renderString (const std::string &text)
 
virtual void setColor (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 
- Public Member Functions inherited from FIFE::FontBase
 FontBase ()
 
virtual ~FontBase ()
 
void invalidate ()
 
void setRowSpacing (int32_t spacing)
 Sets the spacing between rows in pixels. More...
 
int32_t getRowSpacing () const
 Gets the spacing between rows in pixels. More...
 
void setGlyphSpacing (int32_t spacing)
 Sets the spacing between letters in pixels. More...
 
int32_t getGlyphSpacing () const
 Gets the spacing between letters in pixels. More...
 
void setAntiAlias (bool antiAlias)
 Sets the use of anti aliasing. More...
 
bool isAntiAlias ()
 Checks if anti aliasing is used. More...
 
virtual int32_t getStringIndexAt (const std::string &text, int32_t x) const
 
ImagegetAsImage (const std::string &text)
 Gets given text as Image The rsulting image is pooled, so it's not that time critical. More...
 
ImagegetAsImageMultiline (const std::string &text)
 Gets given text as Image. More...
 
std::string splitTextToWidth (const std::string &text, int32_t render_width)
 
SDL_Color getColor () const
 Get the color the text was rendered in. More...
 
- Public Member Functions inherited from FIFE::IFont
virtual ~IFont ()
 
virtual void setColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
 Set the color the text should be rendered in. More...
 

Protected Attributes

TTF_Font * mFont
 
int32_t mHeight
 
int32_t mGlyphSpacing
 
int32_t mRowSpacing
 
std::string mFilename
 
bool mAntiAlias
 
- Protected Attributes inherited from FIFE::FontBase
TextRenderPool m_pool
 
SDL_Color mColor
 
int32_t mGlyphSpacing
 
int32_t mRowSpacing
 
std::string mFilename
 
bool m_antiAlias
 

Detailed Description

SDL True Type Font implementation of Font.

It uses the SDL_ttf library to display True Type Fonts with SDL.

NOTE: You must initialize the SDL_ttf library before using this class. Also, remember to call the SDL_ttf libraries quit function.

Original author of this class is Walluce Pinkham. Some modifications made by the Guichan team, and additonal modifications by the FIFE team.

Definition at line 51 of file truetypefont.h.

Constructor & Destructor Documentation

FIFE::TrueTypeFont::TrueTypeFont ( const std::string &  filename,
int32_t  size 
)

Constructor.

Parameters
filenamethe filename of the True Type Font.
sizethe size the font should be in.

Definition at line 42 of file truetypefont.cpp.

References FIFE::FontBase::mColor, mFilename, and mFont.

FIFE::TrueTypeFont::~TrueTypeFont ( )
virtual

Destructor.

Definition at line 55 of file truetypefont.cpp.

References mFont.

Member Function Documentation

int32_t FIFE::TrueTypeFont::getHeight ( ) const
virtual

gets height of this font

Implements FIFE::IFont.

Definition at line 66 of file truetypefont.cpp.

References FIFE::FontBase::getRowSpacing(), and mFont.

Referenced by renderString().

+ Here is the caller graph for this function:

int32_t FIFE::TrueTypeFont::getWidth ( const std::string &  text) const
virtual

gets width of given text

Implements FIFE::IFont.

Definition at line 59 of file truetypefont.cpp.

References utf8::is_valid(), and mFont.

SDL_Surface * FIFE::TrueTypeFont::renderString ( const std::string &  text)
virtual
void FIFE::TrueTypeFont::setColor ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = 255 
)
virtual

Definition at line 97 of file truetypefont.cpp.

References FIFE::FontBase::mColor.

Member Data Documentation

bool FIFE::TrueTypeFont::mAntiAlias
protected

Definition at line 86 of file truetypefont.h.

std::string FIFE::TrueTypeFont::mFilename
protected

Definition at line 85 of file truetypefont.h.

Referenced by TrueTypeFont().

TTF_Font* FIFE::TrueTypeFont::mFont
protected

Definition at line 79 of file truetypefont.h.

Referenced by getHeight(), getWidth(), renderString(), TrueTypeFont(), and ~TrueTypeFont().

int32_t FIFE::TrueTypeFont::mGlyphSpacing
protected

Definition at line 82 of file truetypefont.h.

int32_t FIFE::TrueTypeFont::mHeight
protected

Definition at line 81 of file truetypefont.h.

int32_t FIFE::TrueTypeFont::mRowSpacing
protected

Definition at line 83 of file truetypefont.h.


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