FifeGUI 0.3.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::sdl3::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
Fontoperator= (Font &&)=default
Fontoperator= (Font const &)=default
virtual ~Font ()=default

Detailed Description

Abstract interface for font rendering.

See also
ImageFont

Definition at line 25 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
graphicsA 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::sdl3::TrueTypeFont.

References Font().

◆ 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 17 of file font.cpp.

References getWidth().

Referenced by getHeight().

◆ 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 its glyphs.

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

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

Referenced by fcn::Button::adjustSizeImpl(), fcn::CheckBox::adjustSizeImpl(), fcn::MenuItem::draw(), and getStringIndexAt().


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