galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::Text Class Referencefinal

String of glyphs rendered with a font. More...

#include <Text.hpp>

+ Collaboration diagram for galaxy::graphics::Text:

Public Types

enum class  Alignment : int { LEFT = 0 , CENTER = 1 , RIGHT = 2 }
 Text alignment. More...
 

Public Member Functions

 Text ()
 Constructor.
 
 Text (Text &&)
 Move constructor.
 
Textoperator= (Text &&)
 Move assignment operator.
 
 ~Text ()
 Destructor.
 
void create (std::string_view text, const float size, const std::string &font, const graphics::Colour &colour, Alignment alignment=Alignment::LEFT)
 Creates the rendered text.
 
void set_font (std::string_view font)
 Update the font used.
 
void update (std::string_view text)
 Update the rendered text.
 
void update (const float size)
 Update the rendered text.
 
void update (const Alignment alignment)
 Update the rendered text.
 
float width () const
 Get text width.
 
float height () const
 Get text height.
 
const std::string & get_text () const
 Get text.
 
float get_size () const
 Get text em size.
 
Alignment get_alignment () const
 Get the text alignment.
 
const std::string & get_font () const
 Get font ID.
 
graphics::VertexArrayvao ()
 Get vertex array.
 
graphics::RenderTexturerender_texture ()
 Get render texture.
 

Public Attributes

graphics::Colour m_colour
 Text colour.
 

Private Member Functions

 Text (const Text &)=delete
 Copy constructor.
 
Textoperator= (const Text &)=delete
 Copy assignment operator.
 
void update ()
 Update the rendered text.
 

Private Attributes

graphics::VertexArray m_vao
 Vertex Array Object.
 
graphics::RenderTexture m_rt
 Font render texture.
 
std::string m_font_name
 Font Name.
 
graphics::Fontm_font
 Pointer to font resource.
 
std::string m_text
 Text.
 
float m_size
 EM size.
 
Alignment m_alignment
 Alignment.
 

Detailed Description

String of glyphs rendered with a font.

Definition at line 22 of file Text.hpp.

Member Enumeration Documentation

◆ Alignment

enum class galaxy::graphics::Text::Alignment : int
strong

Text alignment.

Enumerator
LEFT 
CENTER 
RIGHT 

Definition at line 28 of file Text.hpp.

Constructor & Destructor Documentation

◆ Text() [1/3]

galaxy::graphics::Text::Text ( )

Constructor.

Definition at line 22 of file Text.cpp.

+ Here is the call graph for this function:

◆ Text() [2/3]

galaxy::graphics::Text::Text ( Text && t)

Move constructor.

Definition at line 33 of file Text.cpp.

◆ ~Text()

galaxy::graphics::Text::~Text ( )

Destructor.

Definition at line 66 of file Text.cpp.

◆ Text() [3/3]

galaxy::graphics::Text::Text ( const Text & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

Text & galaxy::graphics::Text::operator= ( Text && t)

Move assignment operator.

Definition at line 47 of file Text.cpp.

◆ create()

void galaxy::graphics::Text::create ( std::string_view text,
const float size,
const std::string & font,
const graphics::Colour & colour,
Alignment alignment = Alignment::LEFT )

Creates the rendered text.

Parameters
textText to display. Supports newlines.
sizeSize of text in em.
fontFont to use.
colourFont colour.
alignmentText alignment. Defaults to LEFT.

Definition at line 71 of file Text.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_font()

void galaxy::graphics::Text::set_font ( std::string_view font)

Update the font used.

Parameters
fontFont to use.

Definition at line 84 of file Text.cpp.

+ Here is the caller graph for this function:

◆ update() [1/4]

void galaxy::graphics::Text::update ( std::string_view text)

Update the rendered text.

Parameters
textText to display. Supports newlines.

Definition at line 158 of file Text.cpp.

+ Here is the call graph for this function:

◆ update() [2/4]

void galaxy::graphics::Text::update ( const float size)

Update the rendered text.

Parameters
sizeSize of text in em.

Definition at line 166 of file Text.cpp.

+ Here is the call graph for this function:

◆ update() [3/4]

void galaxy::graphics::Text::update ( const Alignment alignment)

Update the rendered text.

Parameters
alignmentText alignment.

Definition at line 173 of file Text.cpp.

+ Here is the call graph for this function:

◆ width()

float galaxy::graphics::Text::width ( ) const
nodiscard

Get text width.

Is cached for performance.

Returns
Width as float.

Definition at line 180 of file Text.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ height()

float galaxy::graphics::Text::height ( ) const
nodiscard

Get text height.

Is cached for performance.

Returns
Height as float.

Definition at line 185 of file Text.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_text()

const std::string & galaxy::graphics::Text::get_text ( ) const
nodiscard

Get text.

Is cached for performance.

Returns
Const string reference.

Definition at line 190 of file Text.cpp.

+ Here is the caller graph for this function:

◆ get_size()

float galaxy::graphics::Text::get_size ( ) const
nodiscard

Get text em size.

Is cached for performance.

Returns
Float as EM.

Definition at line 195 of file Text.cpp.

+ Here is the caller graph for this function:

◆ get_alignment()

Text::Alignment galaxy::graphics::Text::get_alignment ( ) const
nodiscard

Get the text alignment.

Returns
Alignment enum.

Definition at line 200 of file Text.cpp.

+ Here is the caller graph for this function:

◆ get_font()

const std::string & galaxy::graphics::Text::get_font ( ) const
nodiscard

Get font ID.

Returns
Const string reference.

Definition at line 205 of file Text.cpp.

+ Here is the caller graph for this function:

◆ vao()

graphics::VertexArray & galaxy::graphics::Text::vao ( )

Get vertex array.

Returns
Reference.

Definition at line 210 of file Text.cpp.

+ Here is the caller graph for this function:

◆ render_texture()

graphics::RenderTexture & galaxy::graphics::Text::render_texture ( )

Get render texture.

Returns
Reference.

Definition at line 215 of file Text.cpp.

+ Here is the caller graph for this function:

◆ operator=() [2/2]

Text & galaxy::graphics::Text::operator= ( const Text & )
privatedelete

Copy assignment operator.

◆ update() [4/4]

void galaxy::graphics::Text::update ( )
private

Update the rendered text.

Definition at line 89 of file Text.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_colour

graphics::Colour galaxy::graphics::Text::m_colour

Text colour.

Definition at line 184 of file Text.hpp.

◆ m_vao

graphics::VertexArray galaxy::graphics::Text::m_vao
private

Vertex Array Object.

Definition at line 190 of file Text.hpp.

◆ m_rt

graphics::RenderTexture galaxy::graphics::Text::m_rt
private

Font render texture.

Definition at line 195 of file Text.hpp.

◆ m_font_name

std::string galaxy::graphics::Text::m_font_name
private

Font Name.

Definition at line 200 of file Text.hpp.

◆ m_font

graphics::Font* galaxy::graphics::Text::m_font
private

Pointer to font resource.

Definition at line 205 of file Text.hpp.

◆ m_text

std::string galaxy::graphics::Text::m_text
private

Text.

Definition at line 210 of file Text.hpp.

◆ m_size

float galaxy::graphics::Text::m_size
private

EM size.

Definition at line 215 of file Text.hpp.

◆ m_alignment

Alignment galaxy::graphics::Text::m_alignment
private

Alignment.

Definition at line 220 of file Text.hpp.


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