OpenXcom  1.0
Open-source clone of the original X-Com
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...
 
SurfacegetChar (UCode 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 (UCode c)
 Gets the size of a particular character;. More...
 
SDL_Color * getPalette () const
 Gets the font's palette. More...
 
void setPalette (SDL_Color *colors, int firstcolor, int ncolors)
 Sets the font's palette. More...
 

Detailed Description

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

Sprite fonts consist of a set of characters split in fixed-size regions.

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

◆ Font()

OpenXcom::Font::Font ( )

Creates a blank font.

Initializes the font with a blank surface.

◆ ~Font()

OpenXcom::Font::~Font ( )

Cleans up the font.

Deletes the font's surface.

Member Function Documentation

◆ getChar()

Surface * OpenXcom::Font::getChar ( UCode  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.

◆ getCharSize()

SDL_Rect OpenXcom::Font::getCharSize ( UCode  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).

◆ getHeight()

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.

◆ getPalette()

SDL_Color * OpenXcom::Font::getPalette ( ) const

Gets the font's palette.

Returns the font's 8bpp palette.

Returns
Pointer to the palette's colors.

◆ getSpacing()

int OpenXcom::Font::getSpacing ( ) const

Gets the spacing between characters.

Returns the spacing between 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 successive characters in a line.

◆ getWidth()

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.

◆ load()

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

Loads the font from YAML.

Loads the font from a YAML file.

Parameters
nodeYAML node.

◆ loadTerminal()

void OpenXcom::Font::loadTerminal ( )

Generate the terminal font.

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

◆ setPalette()

void OpenXcom::Font::setPalette ( SDL_Color *  colors,
int  firstcolor,
int  ncolors 
)

Sets the font's palette.

Replaces a certain amount of colors in the font's palette.

Parameters
colorsPointer to the set of colors.
firstcolorOffset of the first color to replace.
ncolorsAmount of colors to replace.

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