FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::Font Class Referenceabstract

#include <font.hpp>

Inheritance diagram for fcn::Font:
fcn::DefaultFont fcn::ImageFont fcn::sdl2::TrueTypeFont

Public Member Functions

virtual void drawString (Graphics *graphics, std::string const &text, int x, int y)=0
 Font (Font &&)=default
 Font (Font const &)=default
virtual int getHeight () const =0
virtual int getStringIndexAt (std::string const &text, int x) const
virtual int getWidth (std::string const &text) const =0
Font & operator= (Font &&)=default
Font & operator= (Font const &)=default

Detailed Description

Abstract interface for font rendering.

See also
ImageFont

Definition at line 23 of file font.hpp.

Member Function Documentation

◆ drawString()

virtual void fcn::Font::drawString ( Graphics * graphics,
std::string const & text,
int x,
int y )
pure virtual

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.

Implemented in fcn::DefaultFont, fcn::ImageFont, and fcn::sdl2::TrueTypeFont.

◆ getHeight()

◆ getStringIndexAt()

int fcn::Font::getStringIndexAt ( std::string const & text,
int x ) const
virtual

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 in fcn::DefaultFont, and fcn::ImageFont.

Definition at line 11 of file font.cpp.

References getWidth().

Referenced by getHeight(), and fcn::Text::setCaretPosition().

◆ getWidth()

virtual int fcn::Font::getWidth ( std::string const & text) const
pure virtual

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.

Implemented in fcn::DefaultFont, fcn::ImageFont, and fcn::sdl2::TrueTypeFont.

Referenced by fcn::Button::adjustSizeImpl(), fcn::CheckBox::adjustSizeImpl(), fcn::Text::getCaretDimension(), fcn::Text::getCaretX(), fcn::Text::getDimension(), and getStringIndexAt().


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