Practical Tools for Simple Design
Loading...
Searching...
No Matches
Util::Text Class Reference

A class representing a text. More...

#include <Text.hpp>

Inheritance diagram for Util::Text:
Core::Drawable

Public Member Functions

 Text (const std::string &font, int size, const std::string &text, const Util::Color &color=Color(127, 127, 127), bool useAA=true)
 Constructor for the Text class. More...
 
glm::vec2 GetSize () const override
 
void SetText (const std::string &text)
 Sets the text to the specified string. More...
 
void SetColor (const Util::Color &color)
 Sets the color of the text. More...
 
void UseAntiAliasing (bool useAA)
 Sets whether anti-aliasing (AA) should be enabled or disabled. More...
 
void Draw (const Core::Matrices &data) override
 Draws the text with a given transform and z-index. More...
 
virtual void Draw (const Core::Matrices &data)=0
 
virtual glm::vec2 GetSize () const =0
 

Detailed Description

A class representing a text.

This class encapsulates the properties and behaviors of a text. It includes properties such as texture and surface. It also includes behaviors such as drawing the text.

Constructor & Destructor Documentation

◆ Text()

Util::Text::Text ( const std::string &  font,
int  size,
const std::string &  text,
const Util::Color color = Color(127, 127, 127),
bool  useAA = true 
)

Constructor for the Text class.

Parameters
fontThe font file path or name.
sizeThe font size.
textThe text content to render.
colorThe color of the text (default is gray).
useAAFlag indicating whether anti-aliasing should be enabled (default is true).

Member Function Documentation

◆ Draw()

void Util::Text::Draw ( const Core::Matrices data)
overridevirtual

Draws the text with a given transform and z-index.

This function draws the image at the specified z-index and applies the given transform.

Parameters
transformThe transform to apply to the text.
zIndexThe z-index at which to draw the text.

Implements Core::Drawable.

◆ GetSize()

glm::vec2 Util::Text::GetSize ( ) const
inlineoverridevirtual

Implements Core::Drawable.

◆ SetColor()

void Util::Text::SetColor ( const Util::Color color)
inline

Sets the color of the text.

Parameters
colorThe color to set.

◆ SetText()

void Util::Text::SetText ( const std::string &  text)
inline

Sets the text to the specified string.

Parameters
textThe string to set.

◆ UseAntiAliasing()

void Util::Text::UseAntiAliasing ( bool  useAA)

Sets whether anti-aliasing (AA) should be enabled or disabled.

Parameters
useAAA boolean value indicating whether anti-aliasing should be enabled (true) or disabled (false).
Note
This function only sets the internal flag for anti-aliasing and does not directly affect rendering. The actual effect of anti-aliasing depends on the rendering pipeline and the graphics hardware capabilities.
See also
https://en.wikipedia.org/wiki/Spatial_anti-aliasing

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