TGUI
0.10-beta
|
Public Member Functions | |
Font (std::nullptr_t=nullptr) | |
Default constructor which will set the font to nullptr. | |
Font (const String &id) | |
Constructor to create the font from a string (filename by default) More... | |
Font (const char *id) | |
Constructor to create the font from a string (filename by default) More... | |
Font (const void *data, std::size_t sizeInBytes) | |
Constructor to create the font from a byte array. More... | |
Font (std::shared_ptr< BackendFont > backendFont, const String &id) | |
Constructor to create the font from an internal backend font. More... | |
const String & | getId () const |
Returns the id that was used to load the font. More... | |
operator bool () const | |
Converts the font to a boolean to check if it is a nullptr of not. | |
bool | operator== (std::nullptr_t) const |
Compares the font with a nullptr. | |
bool | operator!= (std::nullptr_t) const |
Compares the font with a nullptr. | |
bool | operator== (const Font &right) const |
Compares the font with another one. | |
bool | operator!= (const Font &right) const |
Compares the font with another one. | |
FontGlyph | getGlyph (char32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness=0) const |
Retrieve a glyph of the font. More... | |
float | getKerning (char32_t first, char32_t second, unsigned int characterSize, bool bold=false) const |
Returns the kerning offset of two glyphs. More... | |
float | getLineSpacing (unsigned int characterSize) const |
Returns the line spacing. More... | |
void | setSmooth (bool smooth) |
Enable or disable the smooth filter. More... | |
bool | isSmooth () const |
Tell whether the smooth filter is enabled or not. More... | |
std::shared_ptr< BackendFont > | getBackendFont () const |
Returns the internal font. More... | |
Static Public Member Functions | |
static void | setGlobalFont (const Font &font) |
Changes the global font that is used for all new widgets. More... | |
static Font | getGlobalFont () |
Returns the global font that is used for all new widgets. More... | |
tgui::Font::Font | ( | const String & | id | ) |
Constructor to create the font from a string (filename by default)
id | String to pass to the Deserializer class to load the font |
tgui::Font::Font | ( | const char * | id | ) |
Constructor to create the font from a string (filename by default)
id | String to pass to the Deserializer class to load the font |
tgui::Font::Font | ( | const void * | data, |
std::size_t | sizeInBytes | ||
) |
Constructor to create the font from a byte array.
data | Pointer to the file data in memory |
sizeInBytes | Size of the data to load, in bytes |
tgui::Font::Font | ( | std::shared_ptr< BackendFont > | backendFont, |
const String & | id | ||
) |
Constructor to create the font from an internal backend font.
backendFont | Internal font to use |
id | Id of the font (usually filename) |
std::shared_ptr< BackendFont > tgui::Font::getBackendFont | ( | ) | const |
Returns the internal font.
|
static |
Returns the global font that is used for all new widgets.
FontGlyph tgui::Font::getGlyph | ( | char32_t | codePoint, |
unsigned int | characterSize, | ||
bool | bold, | ||
float | outlineThickness = 0 |
||
) | const |
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) |
const String & tgui::Font::getId | ( | ) | const |
Returns the id that was used to load the font.
float tgui::Font::getKerning | ( | char32_t | first, |
char32_t | second, | ||
unsigned int | characterSize, | ||
bool | bold = false |
||
) | const |
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? |
float tgui::Font::getLineSpacing | ( | unsigned int | characterSize | ) | const |
Returns the line spacing.
Line spacing is the vertical offset to apply between two consecutive lines of text.
characterSize | Size of the characters |
bool tgui::Font::isSmooth | ( | ) | const |
Tell whether the smooth filter is enabled or not.
|
static |
Changes the global font that is used for all new widgets.
font | New global font |
void tgui::Font::setSmooth | ( | bool | smooth | ) |
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 |