TGUI
1.6.1
|
Font implementation that makes use of SFML. More...
#include <TGUI/Backend/Font/SFML-Graphics/BackendFontSFML.hpp>
Public Member Functions | |
bool | loadFromMemory (std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes) override |
Loads a font from memory. | |
bool | hasGlyph (char32_t codePoint) const override |
Returns whether a font contains a certain glyph. | |
FontGlyph | getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override |
Retrieve a glyph of the font. | |
float | getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold) override |
Returns the kerning offset of two glyphs. | |
float | getLineSpacing (unsigned int characterSize) override |
Returns the line spacing. | |
float | getFontHeight (unsigned int characterSize) override |
Returns the height required to render a line of text. | |
float | getAscent (unsigned int characterSize) override |
Returns the maximum height of a glyph above the baseline. | |
float | getDescent (unsigned int characterSize) override |
Returns the maximum height of a glyph below the baseline. | |
float | getUnderlinePosition (unsigned int characterSize) override |
Get the position of the underline. | |
float | getUnderlineThickness (unsigned int characterSize) override |
Get the thickness of the underline. | |
std::shared_ptr< BackendTexture > | getTexture (unsigned int characterSize, unsigned int &textureVersion) override |
Returns the texture that is used to store glyphs of the given character size. | |
Vector2u | getTextureSize (unsigned int characterSize) override |
Returns the size of the texture that is used to store glyphs of the given character size. | |
void | setSmooth (bool smooth) override |
Enable or disable the smooth filter. | |
void | setFontScale (float scale) override |
sf::Font * | getInternalFont () |
bool | loadFromMemory (const void *data, std::size_t sizeInBytes) |
Loads a font from memory. | |
Public Member Functions inherited from tgui::BackendFont | |
BackendFont () | |
Default constructor. | |
BackendFont (const BackendFont &) | |
Copy constructor. | |
BackendFont (BackendFont &&other) noexcept | |
Move constructor. | |
virtual | ~BackendFont () |
Virtual destructor. | |
BackendFont & | operator= (const BackendFont &other) |
Copy assignment operator. | |
BackendFont & | operator= (BackendFont &&other) noexcept |
Move assignment operator. | |
virtual bool | loadFromFile (const String &filename) |
Loads a font from a file. | |
bool | loadFromMemory (const void *data, std::size_t sizeInBytes) |
Loads a font from memory. | |
bool | isSmooth () const |
Tell whether the smooth filter is enabled or not. | |
float | getFontScale () const |
Returns the scale at which glyphs are rendered. | |
Protected Attributes | |
std::unique_ptr< sf::Font > | m_font |
std::unique_ptr< std::uint8_t[]> | m_fileContents |
std::unordered_set< std::uint64_t > | m_loadedGlyphKeys |
std::map< unsigned int, std::shared_ptr< BackendTexture > > | m_textures |
std::map< unsigned int, unsigned int > | m_textureVersions |
Protected Attributes inherited from tgui::BackendFont | |
bool | m_isSmooth = true |
float | m_fontScale = 1 |
Additional Inherited Members | |
Protected Member Functions inherited from tgui::BackendFont | |
std::uint64_t | constructGlyphKey (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) const |
Creates a key for each unique character to render. | |
Font implementation that makes use of SFML.
|
nodiscardoverridevirtual |
Returns the maximum height of a glyph above the baseline.
characterSize | Size of the characters |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns the maximum height of a glyph below the baseline.
characterSize | Size of the characters |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns the height required to render a line of text.
characterSize | Size of the characters |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
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.
codePoint | Unicode code point of the character to get |
characterSize | Reference character size |
bold | Retrieve the bold version or the regular one? |
outlineThickness | Thickness of outline (when != 0 the glyph will not be filled) |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
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.
first | Unicode code point of the first character |
second | Unicode code point of the second character |
characterSize | Size of the characters |
bold | Are the glyphs bold or regular? |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns the line spacing.
Line spacing is the vertical offset to apply between two consecutive lines of text.
characterSize | Size of the characters |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns the texture that is used to store glyphs of the given character size.
characterSize | Size of the characters that should be part of the texture |
textureVersion | Counter that is incremented each time the texture is changed, returned by this function |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns the size of the texture that is used to store glyphs of the given character size.
characterSize | Size of the characters that should be part of the texture |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Get the position of the underline.
Underline position is the vertical offset to apply between the baseline and the underline.
characterSize | Reference character size |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Get the thickness of the underline.
Underline thickness is the vertical size of the underline.
characterSize | Reference character size |
Implements tgui::BackendFont.
|
nodiscardoverridevirtual |
Returns whether a font contains a certain glyph.
codePoint | Character to check |
Implements tgui::BackendFont.
bool tgui::BackendFont::loadFromMemory | ( | const void * | data, |
std::size_t | sizeInBytes ) |
Loads a font from memory.
data | Pointer to the file data in memory |
sizeInBytes | Size of the data to load, in bytes |
This function makes a copy of the data. Use the overload with a unique_ptr when possible to move instead of copy.
|
overridevirtual |
Loads a font from memory.
data | Moved pointer to the file data in memory |
sizeInBytes | Size of the data to load, in bytes |
Implements tgui::BackendFont.
|
overridevirtual |
Reimplemented from tgui::BackendFont.
|
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.
smooth | True to enable smoothing, false to disable it |
Reimplemented from tgui::BackendFont.