25#ifndef TGUI_BACKEND_TEXT_HPP
26#define TGUI_BACKEND_TEXT_HPP
28#include <TGUI/Backend/Font/BackendFont.hpp>
29#include <TGUI/Backend/Renderer/BackendTexture.hpp>
31#include <TGUI/Text.hpp>
40 class TGUI_API BackendText
44 using TextVertexData = std::vector<std::pair<std::shared_ptr<BackendTexture>, std::shared_ptr<std::vector<Vertex>>>>;
47 BackendText(
const BackendText&) =
delete;
48 BackendText(BackendText&&) =
delete;
49 BackendText& operator=(
const BackendText&) =
delete;
50 BackendText& operator=(BackendText&&) =
delete;
144 virtual void setFont(
const std::shared_ptr<BackendFont>& font);
150 [[nodiscard]] std::shared_ptr<BackendFont>
getFont()
const;
172 void updateVertices();
177 static void addGlyphQuad(std::vector<Vertex>& vertices,
187 static void addLine(std::vector<Vertex>& vertices,
193 float outlineThickness,
199 std::shared_ptr<BackendFont> m_font;
200 unsigned int m_lastFontTextureVersion = 0;
205 Color m_outlineColor;
206 float m_outlineThickness = 0;
210 std::shared_ptr<std::vector<Vertex>> m_vertices;
211 std::shared_ptr<std::vector<Vertex>> m_outlineVertices;
212 bool m_verticesNeedUpdate =
true;
std::shared_ptr< BackendFont > getFont() const
Returns the font of the text.
virtual void setFont(const std::shared_ptr< BackendFont > &font)
Changes the font used by the text.
virtual void setOutlineThickness(float thickness)
Changes the thickness of the text outline.
virtual void setStyle(TextStyles style)
Changes the text style.
Color getOutlineColor() const
Returns the text outline color.
virtual void setCharacterSize(unsigned int characterSize)
Sets the size of the characters.
Color getFillColor() const
Returns the text fill color.
float getOutlineThickness() const
Returns the text outline thickness.
virtual Vector2f findCharacterPos(std::size_t index) const
Returns the top-left position of the character at the provided index.
virtual void setString(const String &string)
Changes the text.
virtual void setOutlineColor(const Color &color)
Changes the color of the text outline.
virtual Vector2f getSize()
Returns the size of the text.
BackendText()=default
Default constructor.
TextVertexData getVertexData(bool includeOutline=true, bool includeText=true)
Returns the information that is needed to render this text.
virtual void setFillColor(const Color &color)
Changes the color of the text.
std::vector< std::pair< std::shared_ptr< BackendTexture >, std::shared_ptr< std::vector< Vertex > > > > TextVertexData
Type of the data that is passed to BackendRenderTarget where the actual rendering happens.
Definition BackendText.hpp:44
unsigned int getCharacterSize() const
Returns the character size of the text.
const String & getString() const
Returns the text.
virtual ~BackendText()=default
Virtual destructor.
TextStyles getStyle() const
Returns the style of the text.
Wrapper for colors.
Definition Color.hpp:63
Wrapper class to store strings.
Definition String.hpp:94
Wrapper for text styles.
Definition TextStyle.hpp:55
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
@ Regular
Regular characters, no style.
Definition TextStyle.hpp:39
TGUI_API unsigned int getGlobalTextSize()
Retrieves the default text size used for all new widgets.
Information about a glyph in the font.
Definition Font.hpp:44