Gamedev Framework (gf)  0.11.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...
 
virtual ~ConsoleFont ()
 Destructor. More...
 
Properties
ConsoleFontFormat getFormat () const
 Get the format of the font. More...
 
Vector2u getSize () const
 Get the size of the fonts. More...
 
Vector2u getCharacterSize () const
 Get the size of the characters. More...
 
Mapping
void mapCode (char16_t c, Vector2u position)
 Map a character to a position in the font. More...
 
void mapCodeRange (char16_t c, unsigned count, Vector2u position)
 Map a range of characters to consecutive positions in the font. More...
 
void mapString (StringRef str, Vector2u 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
RectU 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

bool setFormatAndComputeSizes (ConsoleFontFormat format, Vector2u size, Vector2u imageSize)
 Set the format of the font. More...
 
void logFormat (const Path &filename) const
 Print the format of the font. More...
 
Vector2u 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()

gf::ConsoleFont::ConsoleFont ( )

Constructor.

No font is loaded.

◆ ~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()

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

Get the size of the characters.

Returns
The size in pixels of the characters

◆ getColorKeyPosition()

Vector2u 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()

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

Get the size of the fonts.

Returns
The size in characters of the font

◆ getSubTexture()

RectU 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,
Vector2u  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,
unsigned  count,
Vector2u  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,
Vector2u  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

◆ setFormatAndComputeSizes()

bool gf::ConsoleFont::setFormatAndComputeSizes ( ConsoleFontFormat  format,
Vector2u  size,
Vector2u  imageSize 
)
protected

Set the format of the font.

This function sets the format of the font and computes the actual size in characters of the font and the size of the characters.

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