Mana
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TrueTypeFont Class Reference

A wrapper around SDL_ttf for allowing the use of TrueType fonts. More...

#include <truetypefont.h>

Inheritance diagram for TrueTypeFont:

Public Member Functions

 TrueTypeFont (const std::string &filename, int size, int style=0)
 Constructor.
 
 ~TrueTypeFont () override
 
const std::string & filename () const
 
int pointSize () const
 
int style () const
 
int getWidth (const std::string &text) const override
 
int getHeight () const override
 
int getLineHeight () const
 Returns the height of a line of text.
 
void drawString (gcn::Graphics *graphics, const std::string &text, int x, int y) override
 
void drawString (Graphics *graphics, const std::string &text, int x, int y, const std::optional< gcn::Color > &outlineColor, const std::optional< gcn::Color > &shadowColor)
 Extended version of drawString that allows for rendering text with outline and/or shadow.
 

Static Public Member Functions

static void updateFontScale (float scale)
 

Private Member Functions

TextChunkgetChunk (const std::string &text) const
 

Private Attributes

const std::string mFilename
 
TTF_Font * mFont = nullptr
 
TTF_Font * mFontOutline = nullptr
 
const int mPointSize
 
const int mStyle
 
std::list< TextChunkmCache
 

Static Private Attributes

static std::list< TrueTypeFont * > mFonts
 
static float mScale = 1.0f
 

Detailed Description

A wrapper around SDL_ttf for allowing the use of TrueType fonts.

NOTE: This class initializes SDL_ttf as necessary.

Definition at line 42 of file truetypefont.h.

Constructor & Destructor Documentation

◆ TrueTypeFont()

TrueTypeFont::TrueTypeFont ( const std::string &  filename,
int  size,
int  style = 0 
)

Constructor.

Parameters
filenameFont filename.
sizeFont size.

Definition at line 103 of file truetypefont.cpp.

◆ ~TrueTypeFont()

TrueTypeFont::~TrueTypeFont ( )
override

Definition at line 131 of file truetypefont.cpp.

Member Function Documentation

◆ drawString() [1/2]

void TrueTypeFont::drawString ( gcn::Graphics *  graphics,
const std::string &  text,
int  x,
int  y 
)
override
See also
Font::drawString

Definition at line 144 of file truetypefont.cpp.

◆ drawString() [2/2]

void TrueTypeFont::drawString ( Graphics graphics,
const std::string &  text,
int  x,
int  y,
const std::optional< gcn::Color > &  outlineColor,
const std::optional< gcn::Color > &  shadowColor 
)

Extended version of drawString that allows for rendering text with outline and/or shadow.

Definition at line 157 of file truetypefont.cpp.

◆ filename()

const std::string & TrueTypeFont::filename ( ) const
inline

Definition at line 54 of file truetypefont.h.

◆ getChunk()

TextChunk & TrueTypeFont::getChunk ( const std::string &  text) const
private

Definition at line 238 of file truetypefont.cpp.

◆ getHeight()

int TrueTypeFont::getHeight ( ) const
override

Definition at line 228 of file truetypefont.cpp.

◆ getLineHeight()

int TrueTypeFont::getLineHeight ( ) const

Returns the height of a line of text.

This is not the visual height as returned by getHeight() but the recommended spacing between lines of text.

Definition at line 233 of file truetypefont.cpp.

◆ getWidth()

int TrueTypeFont::getWidth ( const std::string &  text) const
override

Definition at line 216 of file truetypefont.cpp.

◆ pointSize()

int TrueTypeFont::pointSize ( ) const
inline

Definition at line 55 of file truetypefont.h.

◆ style()

int TrueTypeFont::style ( ) const
inline

Definition at line 56 of file truetypefont.h.

◆ updateFontScale()

void TrueTypeFont::updateFontScale ( float  scale)
static

Definition at line 189 of file truetypefont.cpp.

Member Data Documentation

◆ mCache

std::list<TextChunk> TrueTypeFont::mCache
mutableprivate

Definition at line 98 of file truetypefont.h.

◆ mFilename

const std::string TrueTypeFont::mFilename
private

Definition at line 90 of file truetypefont.h.

◆ mFont

TTF_Font* TrueTypeFont::mFont = nullptr
private

Definition at line 91 of file truetypefont.h.

◆ mFontOutline

TTF_Font* TrueTypeFont::mFontOutline = nullptr
private

Definition at line 92 of file truetypefont.h.

◆ mFonts

std::list< TrueTypeFont * > TrueTypeFont::mFonts
staticprivate

Definition at line 100 of file truetypefont.h.

◆ mPointSize

const int TrueTypeFont::mPointSize
private

Definition at line 94 of file truetypefont.h.

◆ mScale

float TrueTypeFont::mScale = 1.0f
staticprivate

Definition at line 101 of file truetypefont.h.

◆ mStyle

const int TrueTypeFont::mStyle
private

Definition at line 95 of file truetypefont.h.


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