raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
raylib::Text Class Reference

Text Functions. More...

#include <Text.hpp>

Public Member Functions

 Text (const ::Font &font, const std::string_view text="", float fontSize=10, float spacing=0, const ::Color &color=WHITE)
 Initializes a new Text object with a custom font. More...
 
 Text (const std::string_view text="", float fontSize=10, const ::Color &color=WHITE, const ::Font &font=::GetFontDefault(), float spacing=0)
 Initializes a new Text object. More...
 
void Draw (const ::Vector2 &position) const
 Draw text with values in class. More...
 
void Draw (const ::Vector2 &position, Degree rotation, const ::Vector2 &origin={0, 0}) const
 Draw text using Font and pro parameters (rotation). More...
 
void Draw (int posX, int posY) const
 Draw text with values in class. More...
 
::Color GetColor () const
 Retrieves the color value for the object. More...
 
::Font GetFont () const
 Retrieves the font value for the object. More...
 
float GetFontSize () const
 Retrieves the fontSize value for the object. More...
 
float GetSpacing () const
 Retrieves the spacing value for the object. More...
 
std::string GetText () const
 Retrieves the text value for the object. More...
 
int Measure () const
 Measure string width for default font. More...
 
Vector2 MeasureEx () const
 Measure string size for Font. More...
 
Textoperator= (const Text &other)
 
void SetColor (::Color value)
 Sets the color value for the object. More...
 
void SetFont (::Font value)
 Sets the font value for the object. More...
 
void SetFontSize (float value)
 Sets the fontSize value for the object. More...
 
void SetSpacing (float value)
 Sets the spacing value for the object. More...
 
void SetText (std::string value)
 Sets the text value for the object. More...
 

Static Public Member Functions

static void Draw (const ::Font &font, const std::string_view text, const ::Vector2 &position, const ::Vector2 &origin, const Degree rotation, const float fontSize, const float spacing, const ::Color &color)
 Draw text using font, color, position, origin, font size and spacing. More...
 
static void Draw (const ::Font &font, const std::string_view text, const ::Vector2 &position, const float fontSize, const float spacing, const ::Color &color)
 Draw text using font, color, position, font size and spacing. More...
 
static void Draw (const std::string_view text, const ::Vector2 &pos, const int fontSize, const ::Color &color)
 Draw text using font and color, with position defined as Vector2. More...
 
static void Draw (const std::string_view text, const int posX, const int posY, const int fontSize, const ::Color &color)
 Draw text using font and color. More...
 

Public Attributes

::Color color
 The color of the text. More...
 
::Font font
 The internal raylib font to use for the text. More...
 
float fontSize
 The size of the text. More...
 
float spacing
 The character spacing for the text. More...
 
std::string text
 The internal text. More...
 

Detailed Description

Text Functions.

Definition at line 17 of file Text.hpp.

Constructor & Destructor Documentation

◆ Text() [1/2]

raylib::Text::Text ( const std::string_view  text = "",
float  fontSize = 10,
const ::Color &  color = WHITE,
const ::Font &  font = ::GetFontDefault(),
float  spacing = 0 
)
inline

Initializes a new Text object.

Parameters
textText to initialize.
fontSizeThe size of the text.
colorThe color of the font.
fontFont to initialize.
spacingThe spacing of the text.

Definition at line 53 of file Text.hpp.

◆ Text() [2/2]

raylib::Text::Text ( const ::Font &  font,
const std::string_view  text = "",
float  fontSize = 10,
float  spacing = 0,
const ::Color &  color = WHITE 
)
inline

Initializes a new Text object with a custom font.

Parameters
fontFont to initialize.
textText to initialize.
fontSizeThe size of the text.
spacingThe spacing of the text.
colorThe color of the font.

Definition at line 76 of file Text.hpp.

Member Function Documentation

◆ Draw() [1/7]

static void raylib::Text::Draw ( const ::Font &  font,
const std::string_view  text,
const ::Vector2 &  position,
const ::Vector2 &  origin,
const Degree  rotation,
const float  fontSize,
const float  spacing,
const ::Color &  color 
)
inlinestatic

Draw text using font, color, position, origin, font size and spacing.

See also
DrawTextPro

Definition at line 199 of file Text.hpp.

References color, font, fontSize, spacing, and text.

◆ Draw() [2/7]

static void raylib::Text::Draw ( const ::Font &  font,
const std::string_view  text,
const ::Vector2 &  position,
const float  fontSize,
const float  spacing,
const ::Color &  color 
)
inlinestatic

Draw text using font, color, position, font size and spacing.

See also
DrawTextEx

Definition at line 184 of file Text.hpp.

References color, font, fontSize, spacing, and text.

◆ Draw() [3/7]

void raylib::Text::Draw ( const ::Vector2 &  position) const
inline

Draw text with values in class.

Definition at line 99 of file Text.hpp.

References color, font, fontSize, spacing, and text.

◆ Draw() [4/7]

void raylib::Text::Draw ( const ::Vector2 &  position,
Degree  rotation,
const ::Vector2 &  origin = {0, 0} 
) const
inline

Draw text using Font and pro parameters (rotation).

See also
DrawTextPro()

Definition at line 120 of file Text.hpp.

◆ Draw() [5/7]

static void raylib::Text::Draw ( const std::string_view  text,
const ::Vector2 &  pos,
const int  fontSize,
const ::Color &  color 
)
inlinestatic

Draw text using font and color, with position defined as Vector2.

See also
DrawText

Definition at line 171 of file Text.hpp.

References color, fontSize, and text.

◆ Draw() [6/7]

static void raylib::Text::Draw ( const std::string_view  text,
const int  posX,
const int  posY,
const int  fontSize,
const ::Color &  color 
)
inlinestatic

Draw text using font and color.

See also
DrawText

Definition at line 157 of file Text.hpp.

References color, fontSize, and text.

◆ Draw() [7/7]

void raylib::Text::Draw ( int  posX,
int  posY 
) const
inline

Draw text with values in class.

Definition at line 106 of file Text.hpp.

References color, font, fontSize, spacing, and text.

◆ GetColor()

::Color raylib::Text::GetColor ( ) const
inline

Retrieves the color value for the object.

Returns
The color value of the object.

Definition at line 93 of file Text.hpp.

◆ GetFont()

::Font raylib::Text::GetFont ( ) const
inline

Retrieves the font value for the object.

Returns
The font value of the object.

Definition at line 92 of file Text.hpp.

◆ GetFontSize()

float raylib::Text::GetFontSize ( ) const
inline

Retrieves the fontSize value for the object.

Returns
The fontSize value of the object.

Definition at line 91 of file Text.hpp.

◆ GetSpacing()

float raylib::Text::GetSpacing ( ) const
inline

Retrieves the spacing value for the object.

Returns
The spacing value of the object.

Definition at line 94 of file Text.hpp.

◆ GetText()

std::string raylib::Text::GetText ( ) const
inline

Retrieves the text value for the object.

Returns
The text value of the object.

Definition at line 90 of file Text.hpp.

◆ Measure()

int raylib::Text::Measure ( ) const
inline

Measure string width for default font.

Definition at line 127 of file Text.hpp.

References fontSize, and text.

◆ MeasureEx()

Vector2 raylib::Text::MeasureEx ( ) const
inline

Measure string size for Font.

Definition at line 134 of file Text.hpp.

References font, fontSize, spacing, and text.

◆ operator=()

Text & raylib::Text::operator= ( const Text other)
inline

Definition at line 138 of file Text.hpp.

◆ SetColor()

void raylib::Text::SetColor ( ::Color  value)
inline

Sets the color value for the object.

Parameters
valueThe value of which to set color to.

Definition at line 93 of file Text.hpp.

◆ SetFont()

void raylib::Text::SetFont ( ::Font  value)
inline

Sets the font value for the object.

Parameters
valueThe value of which to set font to.

Definition at line 92 of file Text.hpp.

◆ SetFontSize()

void raylib::Text::SetFontSize ( float  value)
inline

Sets the fontSize value for the object.

Parameters
valueThe value of which to set fontSize to.

Definition at line 91 of file Text.hpp.

◆ SetSpacing()

void raylib::Text::SetSpacing ( float  value)
inline

Sets the spacing value for the object.

Parameters
valueThe value of which to set spacing to.

Definition at line 94 of file Text.hpp.

◆ SetText()

void raylib::Text::SetText ( std::string  value)
inline

Sets the text value for the object.

Parameters
valueThe value of which to set text to.

Definition at line 90 of file Text.hpp.

Member Data Documentation

◆ color

::Color raylib::Text::color

The color of the text.

Definition at line 32 of file Text.hpp.

Referenced by Draw().

◆ font

::Font raylib::Text::font

The internal raylib font to use for the text.

Definition at line 37 of file Text.hpp.

Referenced by Draw(), and MeasureEx().

◆ fontSize

float raylib::Text::fontSize

The size of the text.

Definition at line 27 of file Text.hpp.

Referenced by Draw(), Measure(), and MeasureEx().

◆ spacing

float raylib::Text::spacing

The character spacing for the text.

Definition at line 42 of file Text.hpp.

Referenced by Draw(), and MeasureEx().

◆ text

std::string raylib::Text::text

The internal text.

Definition at line 22 of file Text.hpp.

Referenced by Draw(), Measure(), and MeasureEx().