FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
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 void setBoldStyle (bool style)
 Sets the use of bold style. More...
 
virtual void setItalicStyle (bool style)
 Sets the use of italic style. More...
 
virtual void setUnderlineStyle (bool style)
 Sets the use of underline style. More...
 
virtual void setStrikethroughStyle (bool style)
 Sets the use of strikethrough style. More...
 
virtual int32_t getFontStyleMask () const
 
virtual SDL_Surface * renderString (const std::string &text)
 
virtual void setColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 Set the color the text should be rendered in. More...
 
- 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...
 
virtual void setAntiAlias (bool antiAlias)
 Sets the use of anti aliasing. More...
 
virtual bool isAntiAlias () const
 Checks if anti aliasing is used. More...
 
virtual bool isBoldStyle () const
 Checks if bold style is used. More...
 
virtual bool isItalicStyle () const
 Checks if italic style is used. More...
 
virtual bool isUnderlineStyle () const
 Checks if underline style is used. More...
 
virtual bool isStrikethroughStyle () const
 Checks if strikethrough style is used. More...
 
virtual void setDynamicColoring (bool coloring)
 
virtual bool isDynamicColoring () const
 
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 ()
 

Protected Attributes

TTF_Font * mFont
 
int32_t mFontStyle
 
- Protected Attributes inherited from FIFE::FontBase
TextRenderPool m_pool
 
SDL_Color mColor
 
int32_t mGlyphSpacing
 
int32_t mRowSpacing
 
std::string mFilename
 
bool m_antiAlias
 
bool m_boldStyle
 
bool m_italicStyle
 
bool m_underlineStyle
 
bool m_strikeStyle
 
bool m_coloring
 

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

◆ TrueTypeFont()

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, FIFE::FontBase::mFilename, mFont, and mFontStyle.

◆ ~TrueTypeFont()

FIFE::TrueTypeFont::~TrueTypeFont ( )
virtual

Destructor.

Definition at line 65 of file truetypefont.cpp.

References mFont.

Member Function Documentation

◆ getFontStyleMask()

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

Definition at line 123 of file truetypefont.cpp.

References mFontStyle.

◆ getHeight()

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

gets height of this font

Implements FIFE::IFont.

Definition at line 76 of file truetypefont.cpp.

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

Referenced by renderString().

+ Here is the caller graph for this function:

◆ getWidth()

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

gets width of given text

Implements FIFE::IFont.

Definition at line 69 of file truetypefont.cpp.

References utf8::is_valid(), and mFont.

◆ renderString()

SDL_Surface * FIFE::TrueTypeFont::renderString ( const std::string &  text)
virtual

◆ setBoldStyle()

void FIFE::TrueTypeFont::setBoldStyle ( bool  style)
virtual

Sets the use of bold style.

Parameters
stlyeTrue for use of bold style.

Reimplemented from FIFE::FontBase.

Definition at line 80 of file truetypefont.cpp.

References FIFE::FontBase::m_boldStyle, mFont, and mFontStyle.

◆ setColor()

void FIFE::TrueTypeFont::setColor ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
virtual

Set the color the text should be rendered in.

Implements FIFE::IFont.

Definition at line 154 of file truetypefont.cpp.

References FIFE::FontBase::mColor.

◆ setItalicStyle()

void FIFE::TrueTypeFont::setItalicStyle ( bool  style)
virtual

Sets the use of italic style.

Parameters
stlyeTrue for use of italic style.

Reimplemented from FIFE::FontBase.

Definition at line 92 of file truetypefont.cpp.

References FIFE::FontBase::m_italicStyle, mFont, and mFontStyle.

◆ setStrikethroughStyle()

void FIFE::TrueTypeFont::setStrikethroughStyle ( bool  style)
virtual

Sets the use of strikethrough style.

Parameters
stlyeTrue for use of strikethrough style.

Reimplemented from FIFE::FontBase.

Definition at line 116 of file truetypefont.cpp.

References FIFE::FontBase::m_strikeStyle.

◆ setUnderlineStyle()

void FIFE::TrueTypeFont::setUnderlineStyle ( bool  style)
virtual

Sets the use of underline style.

Parameters
stlyeTrue for use of underline style.

Reimplemented from FIFE::FontBase.

Definition at line 104 of file truetypefont.cpp.

References FIFE::FontBase::m_underlineStyle, mFont, and mFontStyle.

Member Data Documentation

◆ mFont

TTF_Font* FIFE::TrueTypeFont::mFont
protected

◆ mFontStyle

int32_t FIFE::TrueTypeFont::mFontStyle
protected

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