TGUI  0.8-dev
Inheritance diagram for tgui::Text:

Public Member Functions

sf::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 color. More...
 
Color getColor () const
 Returns the text 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...
 
sf::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...
 

Static Public Member Functions

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=sf::Text::Regular)
 
static sf::String wordWrap (float maxWidth, const sf::String &text, Font font, unsigned int textSize, bool bold, bool dropLeadingSpace=true)
 

Member Function Documentation

◆ calculateExtraVerticalSpace()

static float tgui::Text::calculateExtraVerticalSpace ( Font  font,
unsigned int  characterSize,
TextStyle  style = sf::Text::Regular 
)
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.

◆ draw()

void tgui::Text::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const

Draw the text to a render target.

Parameters
targetRender target to draw to
statesCurrent render states

◆ findBestTextSize()

static unsigned int tgui::Text::findBestTextSize ( Font  font,
float  height,
int  fit = 0 
)
static

Finds the best character size for the text.

Parameters
fontFont of the text
heightHeight that the text should fill
fit0 to choose best fit, 1 to select font of at least that height, -1 to select font of maximum that height

◆ findCharacterPos()

sf::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.

Parameters
indexIndex of the character
Returns
Position of the character
Warning
Unlike the function in sf::Text, this function does not take global transformations into account.

◆ getCharacterSize()

unsigned int tgui::Text::getCharacterSize ( ) const

Returns the character size of the text.

Returns
The current text size

◆ getColor()

Color tgui::Text::getColor ( ) const

Returns the text color.

Returns
text color

◆ getFont()

Font tgui::Text::getFont ( ) const

Returns the font of the text.

Returns
text font

◆ getOpacity()

float tgui::Text::getOpacity ( ) const

Returns the opacity of the text.

Returns
text opacity

◆ getSize()

sf::Vector2f tgui::Text::getSize ( ) const

Returns the size of the text.

Returns
Size required for drawing the text

◆ getString()

const sf::String& tgui::Text::getString ( ) const

Returns the text.

Returns
The current text

◆ getStyle()

TextStyle tgui::Text::getStyle ( ) const

Returns the style of the text.

Returns
The current text style

◆ setCharacterSize()

void tgui::Text::setCharacterSize ( unsigned int  size)

Changes the character size of the text.

Parameters
sizeThe new text size

◆ setColor()

void tgui::Text::setColor ( Color  color)

Changes the text color.

Parameters
colorThe new text color

◆ setFont()

void tgui::Text::setFont ( Font  font)

Changes the font used for the text.

Parameters
fontThe new font

◆ setOpacity()

void tgui::Text::setOpacity ( float  opacity)

Changes the opacity of the text.

Parameters
opacityThe text opacity

◆ setString()

void tgui::Text::setString ( const sf::String &  string)

Changes the text.

Parameters
stringThe new text

◆ setStyle()

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.

Parameters
styleNew text style

◆ wordWrap()

static sf::String tgui::Text::wordWrap ( float  maxWidth,
const sf::String &  text,
Font  font,
unsigned int  textSize,
bool  bold,
bool  dropLeadingSpace = true 
)
static

Takes a string and inserts newlines into it so that the width does not exceed maxWidth.

Parameters
maxWidthMaximum width of the text
textThe text to wrap
fontFont of the text
textSizeThe text size
dropLeadingSpaceShould a single space at the beginning of a line be removed?

The documentation for this class was generated from the following file: