TGUI
0.8.9
|
Public Member Functions | |
Vector2f | getSize () const |
Returns the size of the text. More... | |
void | setString (const sf::String &string) |
Changes the text. More... | |
const sf::String & | getString () const |
Returns the text. More... | |
void | setCharacterSize (unsigned int size) |
Changes the character size of the text. More... | |
unsigned int | getCharacterSize () const |
Returns the character size of the text. More... | |
void | setColor (Color color) |
Changes the text fill color. More... | |
Color | getColor () const |
Returns the text fill color. More... | |
void | setOpacity (float opacity) |
Changes the opacity of the text. More... | |
float | getOpacity () const |
Returns the opacity of the text. More... | |
void | setFont (Font font) |
Changes the font used for the text. More... | |
Font | getFont () const |
Returns the font of the text. More... | |
void | setStyle (TextStyle style) |
Changes the style of the text. More... | |
TextStyle | getStyle () const |
Returns the style of the text. More... | |
void | setOutlineColor (Color color) |
Changes the text outline color. More... | |
Color | getOutlineColor () const |
Returns the text outline color. More... | |
void | setOutlineThickness (float thickness) |
Changes the text outline thickness. More... | |
float | getOutlineThickness () const |
Returns the text outline thickness. More... | |
Vector2f | findCharacterPos (std::size_t index) const |
Return the position of the index-th character. More... | |
void | draw (sf::RenderTarget &target, sf::RenderStates states) const |
Draw the text to a render target. More... | |
float | getExtraHorizontalPadding () const |
Returns a small distance that text should be placed from the side of a widget as padding. More... | |
float | getExtraHorizontalOffset () const |
Returns an extra distance that text should be placed from the side of a widget as padding. More... | |
float | getLineHeight () const |
Returns the height of a single line of text. | |
float | getLineWidth () const |
Returns the width of a single line of text. | |
Static Public Member Functions | |
static float | getExtraHorizontalPadding (const Text &text) |
Returns the distance that text should be placed from the side of a widget as padding. | |
static float | getExtraHorizontalPadding (Font font, unsigned int characterSize, TextStyle textStyle={}) |
Returns a small distance that text should be placed from the side of a widget as padding. More... | |
static float | getExtraHorizontalOffset (Font font, unsigned int characterSize, TextStyle textStyle={}) |
Returns an extra distance that text should be placed from the side of a widget as padding. More... | |
static float | getExtraVerticalPadding (unsigned int characterSize) |
Returns the distance that text should be placed from the bottom of the widget as padding. | |
static float | getLineHeight (const Text &text) |
Returns the height of a single line of text. | |
static float | getLineHeight (Font font, unsigned int characterSize, TextStyle textStyle={}) |
Returns the height of a single line of text. | |
static float | getLineWidth (const Text &text) |
Returns the width of a single line of text. | |
static float | getLineWidth (const sf::String &text, Font font, unsigned int characterSize, TextStyle textStyle={}) |
Returns the width of a single line of text. | |
static unsigned int | findBestTextSize (Font font, float height, int fit=0) |
Finds the best character size for the text. More... | |
static float | calculateExtraVerticalSpace (Font font, unsigned int characterSize, TextStyle style={}) |
static sf::String | wordWrap (float maxWidth, const sf::String &text, Font font, unsigned int textSize, bool bold, bool dropLeadingSpace=true) |
|
static |
The line spacing of a font gives the distance between two lines. There may however be an overlap between the highest character on the bottom line and the smallest one on the top line. This function calculates that distance.
void tgui::Text::draw | ( | sf::RenderTarget & | target, |
sf::RenderStates | states | ||
) | const |
Draw the text to a render target.
target | Render target to draw to |
states | Current render states |
|
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 |
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 |
unsigned int tgui::Text::getCharacterSize | ( | ) | const |
Returns the character size of the text.
Color tgui::Text::getColor | ( | ) | const |
Returns the text fill color.
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.
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.
Font tgui::Text::getFont | ( | ) | const |
Returns the font of the text.
float tgui::Text::getOpacity | ( | ) | const |
Returns the opacity of the text.
Color tgui::Text::getOutlineColor | ( | ) | const |
Returns the text outline color.
float tgui::Text::getOutlineThickness | ( | ) | const |
Returns the text outline thickness.
Vector2f tgui::Text::getSize | ( | ) | const |
Returns the size of the text.
const sf::String & tgui::Text::getString | ( | ) | const |
Returns the text.
TextStyle 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 | ( | 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.
color | The new text outline thickness |
void tgui::Text::setString | ( | const sf::String & | string | ) |
Changes the text.
string | The new text |
void tgui::Text::setStyle | ( | TextStyle | style | ) |
Changes the style of the text.
The possible styles can be found in the sf::Text::Style enum. You can also pass a combination of multiple styles, for example sf::Text::Bold | sf::Text::Italic. The default style is sf::Text::Regular.
style | New text style |
|
static |
Takes a string and inserts newlines into it so that the width does not exceed maxWidth.
maxWidth | Maximum width of the text |
text | The text to wrap |
font | Font of the text |
textSize | The text size |
bold | Should the text be bold? |
dropLeadingSpace | Should a single space at the beginning of a line be removed? |