TGUI  0.9-dev
tgui::BackendFontSFML Class Reference

Font implementation that makes use of SFML. More...

#include </home/texus/Documents/TGUI-0.9/include/TGUI/Backend/Font/SFML-Graphics/BackendFontSFML.hpp>

Inheritance diagram for tgui::BackendFontSFML:
tgui::BackendFont

Public Member Functions

bool loadFromMemory (std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes) override
 Loads a font from memory. More...
 
bool hasGlyph (char32_t codePoint) const override
 Returns whether a font contains a certain glyph. More...
 
FontGlyph getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override
 Retrieve a glyph of the font. More...
 
float getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold) override
 Returns the kerning offset of two glyphs. More...
 
float getLineSpacing (unsigned int characterSize) override
 Returns the line spacing. More...
 
float getUnderlinePosition (unsigned int characterSize) override
 Get the position of the underline. More...
 
float getUnderlineThickness (unsigned int characterSize) override
 Get the thickness of the underline. More...
 
std::shared_ptr< BackendTexturegetTexture (unsigned int characterSize) override
 Returns the texture that is used to store glyphs of the given character size. More...
 
void setSmooth (bool smooth) override
 Enable or disable the smooth filter. More...
 
virtual bool loadFromMemory (const void *data, std::size_t sizeInBytes)
 Loads a font from memory. More...
 
virtual bool loadFromMemory (std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes)=0
 Loads a font from memory. More...
 
virtual float getKerning (char32_t first, char32_t second, unsigned int characterSize)
 Returns the kerning offset of two glyphs. More...
 
virtual float getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold)=0
 Returns the kerning offset of two glyphs. More...
 
- Public Member Functions inherited from tgui::BackendFont
virtual ~BackendFont ()=default
 Virtual destructor.
 
virtual bool loadFromFile (const String &filename)
 Loads a font from a file. More...
 
bool isSmooth () const
 Tell whether the smooth filter is enabled or not. More...
 

Additional Inherited Members

- Protected Member Functions inherited from tgui::BackendFont
std::uint64_t constructGlyphKey (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness)
 Creates a key for each unique character to render. More...
 

Detailed Description

Font implementation that makes use of SFML.

Member Function Documentation

◆ getGlyph()

FontGlyph tgui::BackendFontSFML::getGlyph ( char32_t  codePoint,
unsigned int  characterSize,
bool  bold,
float  outlineThickness = 0 
)
overridevirtual

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

Implements tgui::BackendFont.

◆ getKerning() [1/3]

virtual float tgui::BackendFont::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

Reimplemented from tgui::BackendFont.

◆ getKerning() [2/3]

float tgui::BackendFontSFML::getKerning ( char32_t  first,
char32_t  second,
unsigned int  characterSize,
bool  bold 
)
overridevirtual

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

Implements tgui::BackendFont.

◆ getKerning() [3/3]

virtual float tgui::BackendFont::getKerning ( char32_t  first,
char32_t  second,
unsigned int  characterSize,
bool  bold 
)
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

Implements tgui::BackendFont.

◆ getLineSpacing()

float tgui::BackendFontSFML::getLineSpacing ( unsigned int  characterSize)
overridevirtual

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

Implements tgui::BackendFont.

◆ getTexture()

std::shared_ptr< BackendTexture > tgui::BackendFontSFML::getTexture ( unsigned int  characterSize)
overridevirtual

Returns the texture that is used to store glyphs of the given character size.

Parameters
characterSizeSize of the characters that should be part of the texture
Returns
Texture to render text glyphs with

Implements tgui::BackendFont.

◆ getUnderlinePosition()

float tgui::BackendFontSFML::getUnderlinePosition ( unsigned int  characterSize)
overridevirtual

Get the position of the underline.

Underline position is the vertical offset to apply between the baseline and the underline.

Parameters
characterSizeReference character size
Returns
Underline position, in pixels

Implements tgui::BackendFont.

◆ getUnderlineThickness()

float tgui::BackendFontSFML::getUnderlineThickness ( unsigned int  characterSize)
overridevirtual

Get the thickness of the underline.

Underline thickness is the vertical size of the underline.

Parameters
characterSizeReference character size
Returns
Underline thickness, in pixels

Implements tgui::BackendFont.

◆ hasGlyph()

bool tgui::BackendFontSFML::hasGlyph ( char32_t  codePoint) const
overridevirtual

Returns whether a font contains a certain glyph.

Parameters
codePointCharacter to check
Returns
Does the font contain this character?

Implements tgui::BackendFont.

◆ loadFromMemory() [1/3]

virtual bool tgui::BackendFont::loadFromMemory ( const void *  data,
std::size_t  sizeInBytes 
)
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

This function makes a copy of the data. Use the overload with a unique_ptr when possible to move instead of copy.

Reimplemented from tgui::BackendFont.

◆ loadFromMemory() [2/3]

bool tgui::BackendFontSFML::loadFromMemory ( std::unique_ptr< std::uint8_t[]>  data,
std::size_t  sizeInBytes 
)
overridevirtual

Loads a font from memory.

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

Implements tgui::BackendFont.

◆ loadFromMemory() [3/3]

virtual bool tgui::BackendFont::loadFromMemory ( std::unique_ptr< std::uint8_t[]>  data,
std::size_t  sizeInBytes 
)
virtual

Loads a font from memory.

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

Implements tgui::BackendFont.

◆ setSmooth()

void tgui::BackendFontSFML::setSmooth ( bool  smooth)
overridevirtual

Enable or disable the smooth filter.

When the filter is activated, the font appears smoother so that pixels are less noticeable. However if you want the font to look exactly the same as its source file then you should disable it. The smooth filter is enabled by default.

Parameters
smoothTrue to enable smoothing, false to disable it

Reimplemented from tgui::BackendFont.


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