SDL2lazy
Public Member Functions | Public Attributes | Private Attributes | List of all members
SlFont Class Reference

Public Member Functions

 SlFont (std::string name)
 
 ~SlFont ()
 
TTF_Font * font ()
 
void loadFont (std::string fontfile, int fontsize)
 
std::string name ()
 
SDL_Color sdlcolor ()
 
void setAlpha (uint8_t alpha)
 
void setColor (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
 
void setColor (uint8_t red, uint8_t green, uint8_t blue)
 

Public Attributes

short color [4] = {0, 0, 0, 255}
 

Private Attributes

TTF_Font * font_
 
std::string name_
 

Detailed Description

a texture from text.

Constructor & Destructor Documentation

SlFont::SlFont ( std::string  name)

Constructor, makes sure each SlFont has a name.

SlFont::~SlFont ( )

Default destructor. Calls TTF_CloseFont.

Member Function Documentation

TTF_Font* SlFont::font ( )
inline

Direct access to the TTF_Font.

void SlFont::loadFont ( std::string  fontfile,
int  fontsize 
)

Loads font from fontfile. Hangs on to the font until destructor is called.

Exceptions
std::runtime_errorif font can't be loaded.
std::string SlFont::name ( )
inline

The object name cannot be changed after instantiation.

SDL_Color SlFont::sdlcolor ( )

Returns the colour as a SDL_Color struct

void SlFont::setAlpha ( uint8_t  alpha)

Set alpha, leaving colours unchanged.

void SlFont::setColor ( uint8_t  red,
uint8_t  green,
uint8_t  blue,
uint8_t  alpha 
)

Set colours and alpha directly without needing to create an array.

void SlFont::setColor ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

Set colours directly without needing to create an array. Leaves alpha unchanged.

Member Data Documentation

short SlFont::color[4] = {0, 0, 0, 255}

The colour the font will be rendered when creating the texture. (This is not the same as the color mod and alpha mod that may be applied when the resulting SlSprite is rendered.)

TTF_Font* SlFont::font_
private

The actual font. To improve perfomance, the object will keep the font until the destructor is called.

std::string SlFont::name_
private

The object name cannot be changed after instantiation.


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