OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
OpenXcom::Font Class Reference

Takes care of loading and storing each character in a sprite font. More...

#include <Font.h>

Public Member Functions

 Font ()
 Creates a blank font. More...
 
 ~Font ()
 Cleans up the font. More...
 
void load (const YAML::Node &node)
 Loads the font from YAML. More...
 
void loadTerminal ()
 Generate the terminal font. More...
 
void init ()
 Determines the size and position of each character in the font. More...
 
SurfacegetChar (wchar_t c)
 Gets a particular character from the font, with its real size. More...
 
int getWidth () const
 Gets the font's character width. More...
 
int getHeight () const
 Gets the font's character height. More...
 
int getSpacing () const
 Gets the spacing between characters. More...
 
SDL_Rect getCharSize (wchar_t c)
 Gets the size of a particular character;. More...
 
SurfacegetSurface () const
 Gets the font's surface. More...
 

Static Public Member Functions

static bool isLinebreak (wchar_t c)
 Checks if a character is a linebreak.
 
static bool isSpace (wchar_t c)
 Checks if a character is a blank space (includes non-breaking spaces).
 
static bool isSeparator (wchar_t c)
 Checks if a character is a word separator.
 
static bool isNonBreakableSpace (wchar_t c)
 Checks if a character is a non-breaking space.
 
static void setIndex (const std::wstring &index)
 Sets the character index for every font. More...
 

Detailed Description

Takes care of loading and storing each character in a sprite font.

Sprite fonts consist of a set of fixed-size characters all lined up in one column in a surface.

Note
The characters don't all need to be the same size, they can have blank space and will be automatically lined up properly.

Constructor & Destructor Documentation

OpenXcom::Font::Font ( )

Creates a blank font.

Initializes the font with a blank surface.

OpenXcom::Font::~Font ( )

Cleans up the font.

Deletes the font's surface.

Member Function Documentation

Surface * OpenXcom::Font::getChar ( wchar_t  c)

Gets a particular character from the font, with its real size.

Returns a particular character from the set stored in the font.

Parameters
cCharacter to use for size/position.
Returns
Pointer to the font's surface with the respective cropping rectangle set up.
SDL_Rect OpenXcom::Font::getCharSize ( wchar_t  c)

Gets the size of a particular character;.

Returns the dimensions of a particular character in the font.

Parameters
cFont character.
Returns
Width and Height dimensions (X and Y are ignored).
int OpenXcom::Font::getHeight ( ) const

Gets the font's character height.

Returns the maximum height for any character in the font.

Returns
Height in pixels.
int OpenXcom::Font::getSpacing ( ) const

Gets the spacing between characters.

Returns the spacing for any character in the font.

Returns
Spacing in pixels.
Note
This does not refer to character spacing within the surface, but to the spacing used between multiple characters in a line.
Surface * OpenXcom::Font::getSurface ( ) const

Gets the font's surface.

Returns the surface stored within the font.

Used for loading the actual graphic into the font.

Returns
Pointer to the internal surface.
int OpenXcom::Font::getWidth ( ) const

Gets the font's character width.

Returns the maximum width for any character in the font.

Returns
Width in pixels.
void OpenXcom::Font::init ( )

Determines the size and position of each character in the font.

Calculates the real size and position of each character in the surface and stores them in SDL_Rect's for future use by other classes.

void OpenXcom::Font::load ( const YAML::Node &  node)

Loads the font from YAML.

Loads the font from a YAML file.

Parameters
nodeYAML node.
void OpenXcom::Font::loadTerminal ( )

Generate the terminal font.

Generates a pre-defined Codepage 437 (MS-DOS terminal) font.

void OpenXcom::Font::setIndex ( const std::wstring &  index)
static

Sets the character index for every font.

Loads the characters contained in each font from a UTF-8 string to use as the index.

Parameters
indexString of characters.

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