TGUI  0.9.5
Loading...
Searching...
No Matches
tgui::BackendFontBase Class Referenceabstract

Base class for font implementations that depend on the backend. More...

#include <TGUI/BackendFont.hpp>

Public Member Functions

virtual ~BackendFontBase ()=default
 Virtual destructor.
 
virtual bool loadFromFile (const String &filename)=0
 Loads a font from a file.
 
virtual bool loadFromMemory (const void *data, std::size_t sizeInBytes)=0
 Loads a font from memory.
 
virtual FontGlyph getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0)=0
 Retrieve a glyph of the font.
 
virtual float getKerning (char32_t first, char32_t second, unsigned int characterSize)
 Returns the kerning offset of two glyphs.
 
virtual float getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold)=0
 Returns the kerning offset of two glyphs.
 
virtual float getLineSpacing (unsigned int characterSize)=0
 Returns the line spacing.
 

Detailed Description

Base class for font implementations that depend on the backend.

Member Function Documentation

◆ getGlyph()

virtual FontGlyph tgui::BackendFontBase::getGlyph ( char32_t  codePoint,
unsigned int  characterSize,
bool  bold,
float  outlineThickness = 0 
)
pure virtual

Retrieve a glyph of the font.

If the font is a bitmap font, not all character sizes might be available. If the glyph is not available at the requested size, an empty glyph is returned.

Parameters
codePointUnicode code point of the character to get
characterSizeReference character size
boldRetrieve the bold version or the regular one?
outlineThicknessThickness of outline (when != 0 the glyph will not be filled)
Returns
The glyph corresponding to codePoint and characterSize

◆ getKerning() [1/2]

virtual float tgui::BackendFontBase::getKerning ( char32_t  first,
char32_t  second,
unsigned int  characterSize 
)
inlinevirtual

Returns the kerning offset of two glyphs.

The kerning is an extra offset (negative) to apply between two glyphs when rendering them, to make the pair look more "natural". For example, the pair "AV" have a special kerning to make them closer than other characters. Most of the glyphs pairs have a kerning offset of zero, though.

Parameters
firstUnicode code point of the first character
secondUnicode code point of the second character
characterSizeSize of the characters
Returns
Kerning value for first and second, in pixels

◆ getKerning() [2/2]

virtual float tgui::BackendFontBase::getKerning ( char32_t  first,
char32_t  second,
unsigned int  characterSize,
bool  bold 
)
pure virtual

Returns the kerning offset of two glyphs.

The kerning is an extra offset (negative) to apply between two glyphs when rendering them, to make the pair look more "natural". For example, the pair "AV" have a special kerning to make them closer than other characters. Most of the glyphs pairs have a kerning offset of zero, though.

Parameters
firstUnicode code point of the first character
secondUnicode code point of the second character
characterSizeSize of the characters
boldAre the glyphs bold or regular?
Returns
Kerning value for first and second, in pixels

◆ getLineSpacing()

virtual float tgui::BackendFontBase::getLineSpacing ( unsigned int  characterSize)
pure virtual

Returns the line spacing.

Line spacing is the vertical offset to apply between two consecutive lines of text.

Parameters
characterSizeSize of the characters
Returns
Line spacing, in pixels

◆ loadFromFile()

virtual bool tgui::BackendFontBase::loadFromFile ( const String filename)
pure virtual

Loads a font from a file.

Parameters
filenameFilename of the font to load
Returns
True if the font was loaded successfully, false otherwise

◆ loadFromMemory()

virtual bool tgui::BackendFontBase::loadFromMemory ( const void *  data,
std::size_t  sizeInBytes 
)
pure virtual

Loads a font from memory.

Parameters
dataPointer to the file data in memory
sizeInBytesSize of the data to load, in bytes
Returns
True if the font was loaded successfully, false otherwise

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