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

Text Functions. More...

Public Member Functions

 Text (const ::Font &font, const std::string &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 &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.
 
void Draw (const ::Vector2 &position, float 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.
 
::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.
 
Vector2 MeasureEx () const
 Measure string size for Font.
 
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 &text, const ::Vector2 &position, const ::Vector2 &origin, const float 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 &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 &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 &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.
 
::Font font
 The internal raylib font to use for the text.
 
float fontSize
 The size of the text.
 
float spacing
 The character spacing for the text.
 
std::string text
 The internal text.
 

Detailed Description

Text Functions.

Definition at line 14 of file Text.hpp.

Constructor & Destructor Documentation

◆ Text() [1/2]

raylib::Text::Text ( const std::string &  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 50 of file Text.hpp.

◆ Text() [2/2]

raylib::Text::Text ( const ::Font font,
const std::string &  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 73 of file Text.hpp.

Member Function Documentation

◆ Draw() [1/5]

static void raylib::Text::Draw ( const ::Font font,
const std::string &  text,
const ::Vector2 position,
const ::Vector2 origin,
const float  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 183 of file Text.hpp.

References color, raylib::DrawTextPro(), font, fontSize, spacing, and text.

◆ Draw() [2/5]

static void raylib::Text::Draw ( const ::Font font,
const std::string &  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 168 of file Text.hpp.

References color, raylib::DrawTextEx(), font, fontSize, spacing, and text.

◆ Draw() [3/5]

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

Draw text using Font and pro parameters (rotation).

See also
DrawTextPro()

Definition at line 116 of file Text.hpp.

◆ Draw() [4/5]

static void raylib::Text::Draw ( const std::string &  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 159 of file Text.hpp.

References color, raylib::DrawText(), fontSize, and text.

◆ Draw() [5/5]

static void raylib::Text::Draw ( const std::string &  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 150 of file Text.hpp.

References color, raylib::DrawText(), fontSize, 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 90 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 89 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 88 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 91 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 87 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 90 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 89 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 88 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 91 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 87 of file Text.hpp.