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 &text="", float fontSize=10, float spacing=0, const ::Color &color=WHITE)
 Initializes a new Text object with a custom font.
 
 Text (const std::string &text="", float fontSize=10, const ::Color &color=WHITE, const ::Font &font=::GetFontDefault(), float spacing=0)
 Initializes a new Text object.
 
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).
 
void Draw (int posX, int posY) const
 Draw text with values in class.
 
::Color GetColor () const
 Retrieves the color value for the object.
 
::Font GetFont () const
 Retrieves the font value for the object.
 
float GetFontSize () const
 Retrieves the fontSize value for the object.
 
float GetSpacing () const
 Retrieves the spacing value for the object.
 
const std::string & GetText () const
 Retrieves the text value for the object.
 
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.
 
void SetFont (::Font value)
 Sets the font value for the object.
 
void SetFontSize (float value)
 Sets the fontSize value for the object.
 
void SetSpacing (float value)
 Sets the spacing value for the object.
 
void SetText (const std::string &value)
 Sets the text value for the object.
 

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.
 
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.
 
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.
 
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.
 

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/7]

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/7]

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/7]

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

Draw text with values in class.

Definition at line 96 of file Text.hpp.

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

◆ Draw() [4/7]

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() [5/7]

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() [6/7]

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.

◆ Draw() [7/7]

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

Draw text with values in class.

Definition at line 101 of file Text.hpp.

References color, raylib::DrawTextEx(), 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 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()

const 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.

◆ Measure()

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

Measure string width for default font.

Definition at line 123 of file Text.hpp.

References fontSize, and text.

◆ MeasureEx()

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

Measure string size for Font.

Definition at line 128 of file Text.hpp.

References font, fontSize, spacing, and text.

◆ operator=()

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

Definition at line 130 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 ( const 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.

Member Data Documentation

◆ color

::Color raylib::Text::color

The color of the text.

Definition at line 29 of file Text.hpp.

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

◆ font

::Font raylib::Text::font

The internal raylib font to use for the text.

Definition at line 34 of file Text.hpp.

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

◆ fontSize

float raylib::Text::fontSize

The size of the text.

Definition at line 24 of file Text.hpp.

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

◆ spacing

float raylib::Text::spacing

The character spacing for the text.

Definition at line 39 of file Text.hpp.

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

◆ text

std::string raylib::Text::text

The internal text.

Definition at line 19 of file Text.hpp.

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