TGUI
1.6.1
|
Font implementations that uses Raylib to load glyphs. More...
#include <TGUI/Backend/Font/Raylib/BackendFontRaylib.hpp>
Classes | |
struct | Row |
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 |
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 Member Functions | |
FontGlyph | loadGlyph (const GlyphInfo &glyphInfo, char32_t codePoint, unsigned int scaledTextSize, bool bold, float scaledOutlineThickness) |
UIntRect | findAvailableGlyphRect (unsigned int width, unsigned int height) |
int | estimateFontSize (unsigned int scaledTextSize) |
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. | |
Protected Attributes | |
std::unordered_map< std::uint64_t, FontGlyph > | m_glyphs |
unsigned int | m_nextRow = 3 |
Y position of the next new row in the texture (first 2 rows contain pixels for underlining) | |
std::vector< Row > | m_rows |
std::unique_ptr< std::uint8_t[]> | m_fileContents |
std::size_t | m_fileSize = 0 |
std::unique_ptr< std::uint8_t[]> | m_pixels |
std::shared_ptr< BackendTexture > | m_texture |
unsigned int | m_textureSize = 0 |
unsigned int | m_textureVersion = 0 |
std::unordered_map< unsigned int, int > | m_cachedAscents |
std::unordered_map< unsigned int, int > | m_correctedTextSizes |
Protected Attributes inherited from tgui::BackendFont | |
bool | m_isSmooth = true |
float | m_fontScale = 1 |
Font implementations that uses Raylib to load glyphs.
|
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.