TGUI
0.10-beta
|
Font implementations that uses FreeType directly to load glyphs. More...
#include <TGUI/Backend/Font/FreeType/BackendFontFreeType.hpp>
Classes | |
struct | Glyph |
struct | Row |
Public Member Functions | |
~BackendFontFreetype () | |
Destructor that cleans up the FreeType resources. | |
virtual 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... | |
virtual FontGlyph | getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) override |
Retrieve a glyph of the font. More... | |
virtual float | getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold) override |
Returns the kerning offset of two glyphs. More... | |
virtual 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< BackendTexture > | getTexture (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 (std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes)=0 |
Loads a font from memory. More... | |
bool | loadFromMemory (const void *data, std::size_t sizeInBytes) |
Loads a font from memory. 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... | |
virtual bool | loadFromMemory (std::unique_ptr< std::uint8_t[]> data, std::size_t sizeInBytes)=0 |
Loads a font from memory. More... | |
bool | loadFromMemory (const void *data, std::size_t sizeInBytes) |
Loads a font from memory. More... | |
virtual bool | hasGlyph (char32_t codePoint) const =0 |
Returns whether a font contains a certain glyph. More... | |
virtual FontGlyph | getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0)=0 |
Retrieve a glyph of the font. More... | |
virtual float | getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold)=0 |
Returns the kerning offset of two glyphs. More... | |
virtual float | getLineSpacing (unsigned int characterSize)=0 |
Returns the line spacing. More... | |
virtual float | getUnderlinePosition (unsigned int characterSize)=0 |
Get the position of the underline. More... | |
virtual float | getUnderlineThickness (unsigned int characterSize)=0 |
Get the thickness of the underline. More... | |
virtual std::shared_ptr< BackendTexture > | getTexture (unsigned int characterSize)=0 |
Returns the texture that is used to store glyphs of the given character size. More... | |
virtual void | setSmooth (bool smooth) |
Enable or disable the smooth filter. More... | |
bool | isSmooth () const |
Tell whether the smooth filter is enabled or not. More... | |
Protected Member Functions | |
Glyph | loadGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) |
Glyph | getInternalGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness) |
IntRect | findAvailableGlyphRect (unsigned int width, unsigned int height) |
bool | setCurrentSize (unsigned int characterSize) |
void | cleanup () |
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... | |
Protected Attributes | |
FT_Library | m_library = nullptr |
FT_Face | m_face = nullptr |
FT_Stroker | m_stroker = nullptr |
std::unordered_map< unsigned int, float > | m_cachedLineSpacing |
std::unordered_map< std::uint64_t, Glyph > | 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::unique_ptr< std::uint8_t[]> | m_pixels |
std::shared_ptr< BackendTexture > | m_texture |
unsigned int | m_textureSize = 0 |
bool | m_textureUpToDate = false |
Protected Attributes inherited from tgui::BackendFont | |
bool | m_isSmooth = true |
Font implementations that uses FreeType directly to load glyphs.
|
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.
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.
|
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.
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.
|
overridevirtual |
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.
|
overridevirtual |
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 |
Implements tgui::BackendFont.
|
overridevirtual |
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.
|
overridevirtual |
Get the thickness of the underline.
Underline thickness is the vertical size of the underline.
characterSize | Reference character size |
Implements tgui::BackendFont.
|
overridevirtual |
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.
|
virtual |
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 |
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.