--- ---
|
TGUI
1.0-dev
|
Backend-independent wrapper around the backend-specific text class. More...
#include <TGUI/Text.hpp>
Classes | |
| struct | Blueprint |
| Describes a text piece, before turning it into an actual Text object. More... | |
Public Member Functions | |
| Text () | |
| Default constructor. | |
| Text (const Text &) | |
| Text (Text &&) noexcept=default | |
| Text & | operator= (const Text &) |
| Text & | operator= (Text &&) noexcept=default |
| void | setPosition (Vector2f position) |
| Sets the position of the text. | |
| TGUI_NODISCARD Vector2f | getPosition () const |
| Returns the position of the text. | |
| TGUI_NODISCARD Vector2f | getSize () const |
| Returns the size of the text. | |
| void | setString (const String &string) |
| Changes the text. | |
| TGUI_NODISCARD const String & | getString () const |
| Returns the text. | |
| void | setCharacterSize (unsigned int size) |
| Changes the character size of the text. | |
| TGUI_NODISCARD unsigned int | getCharacterSize () const |
| Returns the character size of the text. | |
| void | setColor (Color color) |
| Changes the text fill color. | |
| TGUI_NODISCARD Color | getColor () const |
| Returns the text fill color. | |
| void | setOpacity (float opacity) |
| Changes the opacity of the text. | |
| TGUI_NODISCARD float | getOpacity () const |
| Returns the opacity of the text. | |
| void | setFont (const Font &font) |
| Changes the font used for the text. | |
| TGUI_NODISCARD Font | getFont () const |
| Returns the font of the text. | |
| void | setStyle (TextStyles style) |
| Changes the style of the text. | |
| TGUI_NODISCARD TextStyles | getStyle () const |
| Returns the style of the text. | |
| void | setOutlineColor (Color color) |
| Changes the text outline color. | |
| TGUI_NODISCARD Color | getOutlineColor () const |
| Returns the text outline color. | |
| void | setOutlineThickness (float thickness) |
| Changes the text outline thickness. | |
| TGUI_NODISCARD float | getOutlineThickness () const |
| Returns the text outline thickness. | |
| TGUI_NODISCARD Vector2f | findCharacterPos (std::size_t index) const |
| Return the position of the index-th character. | |
| TGUI_NODISCARD float | getExtraHorizontalPadding () const |
| Returns a small distance that text should be placed from the side of a widget as padding. | |
| TGUI_NODISCARD float | getExtraHorizontalOffset () const |
| Returns an extra distance that text should be placed from the side of a widget as padding. | |
| TGUI_NODISCARD float | getLineHeight () const |
| Returns the height of a single line of text. | |
| TGUI_NODISCARD float | getLineWidth () const |
| Returns the width of a single line of text. | |
| TGUI_NODISCARD std::shared_ptr< BackendText > | getBackendText () const |
| Returns the internal text. | |
Static Public Member Functions | |
| static TGUI_NODISCARD float | getExtraHorizontalPadding (const Font &font, unsigned int characterSize) |
| Returns a small distance that text should be placed from the side of a widget as padding. | |
| static TGUI_NODISCARD float | getExtraHorizontalOffset (const Font &font, unsigned int characterSize) |
| Returns an extra distance that text should be placed from the side of a widget as padding. | |
| static TGUI_NODISCARD float | getExtraVerticalPadding (unsigned int characterSize) |
| Returns the distance that text should be placed from the bottom of the widget as padding. | |
| static TGUI_NODISCARD float | getLineHeight (const Font &font, unsigned int characterSize) |
| Returns the height of a single line of text. | |
| static TGUI_NODISCARD float | getLineWidth (const String &text, const Font &font, unsigned int characterSize, TextStyles textStyle={}) |
| Returns the width of a single line of text. | |
| static TGUI_NODISCARD unsigned int | findBestTextSize (const Font &font, float height, int fit=0) |
| Finds the best character size for the text. | |
| static TGUI_NODISCARD String | wordWrap (float maxWidth, const String &text, const Font &font, unsigned int textSize, bool bold) |
| static TGUI_NODISCARD std::vector< std::vector< Blueprint > > | wordWrap (float maxWidth, const std::vector< std::vector< Blueprint > > &lines, const Font &font) |
Backend-independent wrapper around the backend-specific text class.
|
static |
Finds the best character size for the text.
| font | Font of the text |
| height | Height that the text should fill |
| fit | 0 to choose best fit, 1 to select font of at least that height, -1 to select font of maximum that height |
| TGUI_NODISCARD Vector2f tgui::Text::findCharacterPos | ( | std::size_t | index | ) | const |
Return the position of the index-th character.
If index is out of range, the position of the end of the string is returned.
| index | Index of the character |
| TGUI_NODISCARD std::shared_ptr< BackendText > tgui::Text::getBackendText | ( | ) | const |
Returns the internal text.
| TGUI_NODISCARD unsigned int tgui::Text::getCharacterSize | ( | ) | const |
Returns the character size of the text.
| TGUI_NODISCARD Color tgui::Text::getColor | ( | ) | const |
Returns the text fill color.
| TGUI_NODISCARD float tgui::Text::getExtraHorizontalOffset | ( | ) | const |
Returns an extra distance that text should be placed from the side of a widget as padding.
This distance is slightly larger than getExtraHorizontalPadding.
|
static |
Returns an extra distance that text should be placed from the side of a widget as padding.
This distance is slightly larger than getExtraHorizontalPadding.
| TGUI_NODISCARD float tgui::Text::getExtraHorizontalPadding | ( | ) | const |
Returns a small distance that text should be placed from the side of a widget as padding.
This distance is slightly smaller than getExtraHorizontalOffset.
|
static |
Returns a small distance that text should be placed from the side of a widget as padding.
This distance is slightly smaller than getExtraHorizontalOffset.
| TGUI_NODISCARD Font tgui::Text::getFont | ( | ) | const |
Returns the font of the text.
| TGUI_NODISCARD float tgui::Text::getOpacity | ( | ) | const |
Returns the opacity of the text.
| TGUI_NODISCARD Color tgui::Text::getOutlineColor | ( | ) | const |
Returns the text outline color.
| TGUI_NODISCARD float tgui::Text::getOutlineThickness | ( | ) | const |
Returns the text outline thickness.
| TGUI_NODISCARD Vector2f tgui::Text::getPosition | ( | ) | const |
Returns the position of the text.
| TGUI_NODISCARD Vector2f tgui::Text::getSize | ( | ) | const |
Returns the size of the text.
| TGUI_NODISCARD const String & tgui::Text::getString | ( | ) | const |
Returns the text.
| TGUI_NODISCARD TextStyles tgui::Text::getStyle | ( | ) | const |
Returns the style of the text.
| void tgui::Text::setCharacterSize | ( | unsigned int | size | ) |
Changes the character size of the text.
| size | The new text size |
| void tgui::Text::setColor | ( | Color | color | ) |
Changes the text fill color.
| color | The new text color |
| void tgui::Text::setFont | ( | const Font & | font | ) |
Changes the font used for the text.
| font | The new font |
| void tgui::Text::setOpacity | ( | float | opacity | ) |
Changes the opacity of the text.
| opacity | The text opacity |
| void tgui::Text::setOutlineColor | ( | Color | color | ) |
Changes the text outline color.
| color | The new text outline color |
| void tgui::Text::setOutlineThickness | ( | float | thickness | ) |
Changes the text outline thickness.
| thickness | The new text outline thickness |
| void tgui::Text::setPosition | ( | Vector2f | position | ) |
Sets the position of the text.
| position | Position of the text |
| void tgui::Text::setString | ( | const String & | string | ) |
Changes the text.
| string | The new text |
| void tgui::Text::setStyle | ( | TextStyles | style | ) |
Changes the style of the text.
The possible styles can be found in the tgui::TextStyle::Style enum. You can also pass a combination of multiple styles, for example tgui::TextStyle::Bold | tgui::TextStyle::Italic. The default style is tgui::TextStyle::Regular.
| style | New text style |
|
static |
Takes multiple lines of potentially multiple text pieces, and splits lines so that the width does not exceed maxWidth
| maxWidth | Maximum width of the text |
| lines | Existing lines that need to be split if they are too long |
| font | Font of the text |
| textSize | The text size |
| bold | Should the text be bold? |