FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::DefaultFont Class Reference

#include <defaultfont.hpp>

Inheritance diagram for fcn::DefaultFont:
fcn::Font

Public Member Functions

virtual int drawGlyph (Graphics *graphics, unsigned char glyph, int x, int y)
void drawString (Graphics *graphics, std::string const &text, int x, int y) override
int getHeight () const override
int getStringIndexAt (std::string const &text, int x) const override
int getWidth (std::string const &text) const override
Public Member Functions inherited from fcn::Font
 Font (Font &&)=default
 Font (Font const &)=default
Font & operator= (Font &&)=default
Font & operator= (Font const &)=default

Detailed Description

A basic font implementation capable only of drawing rectangles (placeholder).

This font is used as a default font when no other font is specified.

Definition at line 22 of file defaultfont.hpp.

Member Function Documentation

◆ drawGlyph()

int fcn::DefaultFont::drawGlyph ( Graphics * graphics,
unsigned char glyph,
int x,
int y )
virtual

Draws a glyph as a rectangle.

The glyphs will always be drawn as rectangles no matter the glyph.

NOTE: You normally won't use this function to draw text since the Graphics class contains better functions for drawing text.

Parameters
Graphics & RenderingA Graphics object to be used for drawing.
glyphThe glyph to draw.
xThe x coordinate where to draw the glyph.
yThe y coordinate where to draw the glyph.
Returns
The width of the drawn glyph in pixels.

Definition at line 23 of file defaultfont.cpp.

References fcn::Graphics::drawRectangle().

Referenced by drawString().

◆ drawString()

void fcn::DefaultFont::drawString ( Graphics * graphics,
std::string const & text,
int x,
int y )
overridevirtual

Draws a string.

NOTE: You normally won't use this function to draw text since Graphics contains better functions for drawing text.

Parameters
Graphics & RenderingA Graphics object to use for drawing.
textThe string to draw.
xThe x coordinate where to draw the string.
yThe y coordinate where to draw the string.

Implements fcn::Font.

Definition at line 32 of file defaultfont.cpp.

References drawGlyph(), and getWidth().

◆ getHeight()

int fcn::DefaultFont::getHeight ( ) const
overridevirtual

Gets the height of the glyphs in the font.

Returns
The height of the glyphs int the font.

Implements fcn::Font.

Definition at line 13 of file defaultfont.cpp.

◆ getStringIndexAt()

int fcn::DefaultFont::getStringIndexAt ( std::string const & text,
int x ) const
overridevirtual

Gets a string index in a string providing an x coordinate.

Used to retrieve a string index (for a character in a string) at a certain x position. It is especially useful when a mouse clicks in a TextField and you want to know which character was clicked.

Returns
A string index in a string providing an x coordinate.

Reimplemented from fcn::Font.

Definition at line 41 of file defaultfont.cpp.

References getWidth().

◆ getWidth()

int fcn::DefaultFont::getWidth ( std::string const & text) const
overridevirtual

Gets the width of a string.

The width of a string is not necessarily the sum of all the widths of it's glyphs.

Parameters
textThe string to return the width of.
Returns
The width of a string.

Implements fcn::Font.

Definition at line 18 of file defaultfont.cpp.

Referenced by drawString(), and getStringIndexAt().


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