3// SFML - Simple and Fast Multimedia Library 4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org) 6// This software is provided 'as-is', without any express or implied warranty. 7// In no event will the authors be held liable for any damages arising from the use of this software. 9// Permission is granted to anyone to use this software for any purpose, 10// including commercial applications, and to alter it and redistribute it freely, 11// subject to the following restrictions: 13// 1. The origin of this software must not be misrepresented; 14// you must not claim that you wrote the original software. 15// If you use this software in a product, an acknowledgment 16// in the product documentation would be appreciated but is not required. 18// 2. Altered source versions must be plainly marked as such, 19// and must not be misrepresented as being the original software. 21// 3. This notice may not be removed or altered from any source distribution. 93Text(
constFont&& font,
Stringstring =
"",
unsignedint characterSize = 30) =
delete;
410void ensureGeometryUpdate()
const;
417unsignedint m_characterSize{30};
418float m_letterSpacingFactor{1.f};
419float m_lineSpacingFactor{1.f};
420 std::uint32_t m_style{Regular};
421 Color m_fillColor{Color::White};
422 Color m_outlineColor{Color::Black};
423float m_outlineThickness{0.f};
424mutable VertexArray m_vertices{PrimitiveType::Triangles};
425mutable VertexArray m_outlineVertices{PrimitiveType::Triangles};
427mutablebool m_geometryNeedUpdate{};
428mutable std::uint64_t m_fontTextureId{};
#define SFML_GRAPHICS_API
Utility class for manipulating RGBA colors.
Abstract base class for objects that can be drawn to a render target.
friend class RenderTarget
Class for loading and manipulating character fonts.
Base class for all render targets (window, texture, ...)
Utility string class that automatically handles conversions between types and encodings.
const Font & getFont() const
Get the text's font.
float getLetterSpacing() const
Get the size of the letter spacing factor.
Text(const Font &font, String string="", unsigned int characterSize=30)
Construct the text from a string, font and size.
void setFont(const Font &font)
Set the text's font.
Vector2f findCharacterPos(std::size_t index) const
Return the position of the index-th character.
void setFillColor(Color color)
Set the fill color of the text.
FloatRect getLocalBounds() const
Get the local bounding rectangle of the entity.
unsigned int getCharacterSize() const
Get the character size.
void setFont(const Font &&font)=delete
Disallow setting from a temporary font.
float getLineSpacing() const
Get the size of the line spacing factor.
void setOutlineColor(Color color)
Set the outline color of the text.
void setString(const String &string)
Set the text's string.
std::uint32_t getStyle() const
Get the text's style.
void setStyle(std::uint32_t style)
Set the text's style.
Style
Enumeration of the string drawing styles.
@ Regular
Regular characters, no style.
@ Underlined
Underlined characters.
@ StrikeThrough
Strike through characters.
@ Italic
Italic characters.
Color getOutlineColor() const
Get the outline color of the text.
void setOutlineThickness(float thickness)
Set the thickness of the text's outline.
const String & getString() const
Get the text's string.
void setLetterSpacing(float spacingFactor)
Set the letter spacing factor.
FloatRect getGlobalBounds() const
Get the global bounding rectangle of the entity.
Text(const Font &&font, String string="", unsigned int characterSize=30)=delete
Disallow construction from a temporary font.
Color getFillColor() const
Get the fill color of the text.
void setCharacterSize(unsigned int size)
Set the character size.
void setLineSpacing(float spacingFactor)
Set the line spacing factor.
float getOutlineThickness() const
Get the outline thickness of the text.
Transformable()=default
Default constructor.
Vector2< float > Vector2f
Define the states used for drawing to a RenderTarget