TGUI  1.4.0
Loading...
Searching...
No Matches

Base class for text implementations that depend on the backend. More...

#include <TGUI/Backend/Renderer/BackendText.hpp>

Public Types

using TextVertexData = std::vector<std::pair<std::shared_ptr<BackendTexture>, std::shared_ptr<std::vector<Vertex>>>>
 Type of the data that is passed to BackendRenderTarget where the actual rendering happens.
 

Public Member Functions

 BackendText (const BackendText &)=delete
 
 BackendText (BackendText &&)=delete
 
BackendTextoperator= (const BackendText &)=delete
 
BackendTextoperator= (BackendText &&)=delete
 
 BackendText ()=default
 Default constructor.
 
virtual ~BackendText ()=default
 Virtual destructor.
 
virtual TGUI_NODISCARD Vector2f getSize ()
 Returns the size of the text.
 
virtual void setString (const String &string)
 Changes the text.
 
TGUI_NODISCARD const StringgetString () const
 Returns the text.
 
virtual void setCharacterSize (unsigned int characterSize)
 Sets the size of the characters.
 
TGUI_NODISCARD unsigned int getCharacterSize () const
 Returns the character size of the text.
 
virtual void setFillColor (const Color &color)
 Changes the color of the text.
 
TGUI_NODISCARD Color getFillColor () const
 Returns the text fill color.
 
virtual void setOutlineColor (const Color &color)
 Changes the color of the text outline.
 
TGUI_NODISCARD Color getOutlineColor () const
 Returns the text outline color.
 
virtual void setOutlineThickness (float thickness)
 Changes the thickness of the text outline.
 
TGUI_NODISCARD float getOutlineThickness () const
 Returns the text outline thickness.
 
virtual void setStyle (TextStyles style)
 Changes the text style.
 
TGUI_NODISCARD TextStyles getStyle () const
 Returns the style of the text.
 
virtual void setFont (const std::shared_ptr< BackendFont > &font)
 Changes the font used by the text.
 
TGUI_NODISCARD std::shared_ptr< BackendFontgetFont () const
 Returns the font of the text.
 
virtual TGUI_NODISCARD Vector2f findCharacterPos (std::size_t index) const
 Returns the top-left position of the character at the provided index.
 
TGUI_NODISCARD TextVertexData getVertexData ()
 Returns the information that is needed to render this text.
 

Protected Member Functions

void updateVertices ()
 
void addGlyphQuad (std::vector< Vertex > &vertices, Vector2f position, const Vertex::Color &color, const FontGlyph &glyph, float fontScale, float italicShear)
 
void addLine (std::vector< Vertex > &vertices, float lineLength, float lineTop, const Vertex::Color &color, float offset, float thickness, float outlineThickness, float fontScale)
 

Protected Attributes

std::shared_ptr< BackendFontm_font
 
unsigned int m_lastFontTextureVersion = 0
 
String m_string
 
unsigned int m_characterSize = getGlobalTextSize()
 
Color m_fillColor
 
Color m_outlineColor
 
float m_outlineThickness = 0
 
TextStyles m_style = TextStyle::Regular
 
Vector2f m_size
 
std::shared_ptr< std::vector< Vertex > > m_vertices
 
std::shared_ptr< std::vector< Vertex > > m_outlineVertices
 
bool m_verticesNeedUpdate = true
 

Detailed Description

Base class for text implementations that depend on the backend.

Member Function Documentation

◆ findCharacterPos()

virtual TGUI_NODISCARD Vector2f tgui::BackendText::findCharacterPos ( std::size_t index) const
virtual

Returns the top-left position of the character at the provided index.

Parameters
indexIndex of the character for which the position should be returned

◆ getCharacterSize()

TGUI_NODISCARD unsigned int tgui::BackendText::getCharacterSize ( ) const

Returns the character size of the text.

Returns
The current text size

◆ getFillColor()

TGUI_NODISCARD Color tgui::BackendText::getFillColor ( ) const

Returns the text fill color.

Returns
text color

◆ getFont()

TGUI_NODISCARD std::shared_ptr< BackendFont > tgui::BackendText::getFont ( ) const

Returns the font of the text.

Returns
text font

◆ getOutlineColor()

TGUI_NODISCARD Color tgui::BackendText::getOutlineColor ( ) const

Returns the text outline color.

Returns
outline color

◆ getOutlineThickness()

TGUI_NODISCARD float tgui::BackendText::getOutlineThickness ( ) const

Returns the text outline thickness.

Returns
text outline thickness

◆ getSize()

virtual TGUI_NODISCARD Vector2f tgui::BackendText::getSize ( )
virtual

Returns the size of the text.

Returns
Size of the bounding box around the text

◆ getString()

TGUI_NODISCARD const String & tgui::BackendText::getString ( ) const

Returns the text.

Returns
The current text

◆ getStyle()

TGUI_NODISCARD TextStyles tgui::BackendText::getStyle ( ) const

Returns the style of the text.

Returns
The current text style

◆ getVertexData()

TGUI_NODISCARD TextVertexData tgui::BackendText::getVertexData ( )

Returns the information that is needed to render this text.

Returns
Data that contains the textures and vertices used by this text

◆ setCharacterSize()

virtual void tgui::BackendText::setCharacterSize ( unsigned int characterSize)
virtual

Sets the size of the characters.

Parameters
characterSizeMaximum size available for characters above the baseline

◆ setFillColor()

virtual void tgui::BackendText::setFillColor ( const Color & color)
virtual

Changes the color of the text.

Parameters
colorText color

◆ setFont()

virtual void tgui::BackendText::setFont ( const std::shared_ptr< BackendFont > & font)
virtual

Changes the font used by the text.

Parameters
fontNew text font

◆ setOutlineColor()

virtual void tgui::BackendText::setOutlineColor ( const Color & color)
virtual

Changes the color of the text outline.

Parameters
colorOutline color

◆ setOutlineThickness()

virtual void tgui::BackendText::setOutlineThickness ( float thickness)
virtual

Changes the thickness of the text outline.

Parameters
thicknessOutline thickness

◆ setString()

virtual void tgui::BackendText::setString ( const String & string)
virtual

Changes the text.

Parameters
stringText that should be displayed

◆ setStyle()

virtual void tgui::BackendText::setStyle ( TextStyles style)
virtual

Changes the text style.

Parameters
styleNew text style

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