Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | Protected Member Functions | List of all members
gf::ConsoleFont Class Referenceabstract

A console font. More...

#include <gf/ConsoleFont.h>

Inheritance diagram for gf::ConsoleFont:
Inheritance graph
[legend]

Public Member Functions

 ConsoleFont ()
 Constructor. More...
 
 ConsoleFont (const Image &image, ConsoleFontFormat format, Vector2i size)
 Constructor. More...
 
virtual ~ConsoleFont ()
 Destructor. More...
 
Properties
ConsoleFontFormat getFormat () const
 Get the format of the font. More...
 
Vector2i getSize () const
 Get the size of the fonts. More...
 
Vector2i getCharacterSize () const
 Get the size of the characters. More...
 
Mapping
void mapCode (char16_t c, Vector2i position)
 Map a character to a position in the font. More...
 
void mapCodeRange (char16_t c, int count, Vector2i position)
 Map a range of characters to consecutive positions in the font. More...
 
void mapString (StringRef str, Vector2i position)
 Map characters from a string to consecutive positions in the font. More...
 
void mapElement (ConsoleFontElement element)
 Map an element in the font. More...
 
void mapElements (ArrayRef< ConsoleFontElement > elements)
 Map some elements in the font. More...
 
void clearMapping ()
 Clear the mapping. More...
 
Texture
RectI getSubTexture (char16_t c) const
 Get the sub-texture rectangle. More...
 
RectF getTextureRect (char16_t c) const
 Get the texture rectangle for a character. More...
 
virtual const BareTexturegetTexture () const =0
 Get the texture of the console font. More...
 

Protected Member Functions

void logFormat (const Path &filename) const
 Print the format of the font. More...
 
Vector2i getColorKeyPosition () const
 Get the color key position. More...
 

Detailed Description

A console font.

See also
gf::Console, gf::ConsoleFontFormat, gf::ConsoleFontElement

Constructor & Destructor Documentation

◆ ConsoleFont() [1/2]

gf::ConsoleFont::ConsoleFont ( )

Constructor.

No font is loaded.

◆ ConsoleFont() [2/2]

gf::ConsoleFont::ConsoleFont ( const Image image,
ConsoleFontFormat  format,
Vector2i  size 
)

Constructor.

Parameters
imageThe image used by the font
formatThe format of the font
sizeThe size given by the user, may be \( (0, 0) \)

◆ ~ConsoleFont()

virtual gf::ConsoleFont::~ConsoleFont ( )
virtual

Destructor.

Member Function Documentation

◆ clearMapping()

void gf::ConsoleFont::clearMapping ( )

Clear the mapping.

All characters are mapped to the first position in the font.

◆ getCharacterSize()

Vector2i gf::ConsoleFont::getCharacterSize ( ) const
inline

Get the size of the characters.

Returns
The size in pixels of the characters

◆ getColorKeyPosition()

Vector2i gf::ConsoleFont::getColorKeyPosition ( ) const
protected

Get the color key position.

This function gives the position of a pixel of the space character in the font.

Returns
A pixel position where to find the color key

◆ getFormat()

ConsoleFontFormat gf::ConsoleFont::getFormat ( ) const
inline

Get the format of the font.

◆ getSize()

Vector2i gf::ConsoleFont::getSize ( ) const
inline

Get the size of the fonts.

Returns
The size in characters of the font

◆ getSubTexture()

RectI gf::ConsoleFont::getSubTexture ( char16_t  c) const

Get the sub-texture rectangle.

Parameters
cA character
Returns
The corresponding sub-texture rectangle
See also
getTexture(), getTextureRect()

◆ getTexture()

virtual const BareTexture* gf::ConsoleFont::getTexture ( ) const
pure virtual

Get the texture of the console font.

Returns
The texture of the font

Implemented in gf::ColoredConsoleFont, and gf::BitmapConsoleFont.

◆ getTextureRect()

RectF gf::ConsoleFont::getTextureRect ( char16_t  c) const

Get the texture rectangle for a character.

Parameters
cA character
Returns
The corresponding texture rectangle
See also
getTexture(), getSubTexture()

◆ logFormat()

void gf::ConsoleFont::logFormat ( const Path filename) const
protected

Print the format of the font.

This function logs the format of the font

Parameters
filenameThe filename of the source image

◆ mapCode()

void gf::ConsoleFont::mapCode ( char16_t  c,
Vector2i  position 
)

Map a character to a position in the font.

Parameters
cA character
positionThe position, in characters, of the character

◆ mapCodeRange()

void gf::ConsoleFont::mapCodeRange ( char16_t  c,
int  count,
Vector2i  position 
)

Map a range of characters to consecutive positions in the font.

Parameters
cThe first character in the range
countThe number of character in the range
positionThe position, in characters, of the first character

◆ mapElement()

void gf::ConsoleFont::mapElement ( ConsoleFontElement  element)

Map an element in the font.

Parameters
elementA font element

◆ mapElements()

void gf::ConsoleFont::mapElements ( ArrayRef< ConsoleFontElement elements)

Map some elements in the font.

Parameters
elementsThe font elements

◆ mapString()

void gf::ConsoleFont::mapString ( StringRef  str,
Vector2i  position 
)

Map characters from a string to consecutive positions in the font.

Parameters
strThe string with the characters
positionThe position, in characters, of the first character of the string