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::Font Class Referencefinal

A font is a MSDF atlas of glyphs. More...

#include <Font.hpp>

+ Collaboration diagram for galaxy::graphics::Font:

Public Member Functions

 Font ()
 Constructor.
 
 Font (Font &&)
 Move constructor.
 
Fontoperator= (Font &&)
 Move assignment operator.
 
 ~Font ()
 Destructor.
 
bool load (const std::string &file)
 Loads the font and sets up characters.
 
bool load (unsigned char *buffer, const unsigned int size)
 Loads the font and sets up characters.
 
void build ()
 Build the font atlas.
 
float vertical_advance (const float size) const
 Get vertical advance for drawing multiline text.
 
glm::vec2 get_text_size (const std::string &text, const float size)
 Query text size with font.
 
msdfgl_font_t handle ()
 Get handle to internal font object.
 

Private Attributes

msdfgl_font_t m_font
 Font object.
 
FT_Face m_face
 Freetype face.
 

Detailed Description

A font is a MSDF atlas of glyphs.

Definition at line 24 of file Font.hpp.

Constructor & Destructor Documentation

◆ Font() [1/2]

galaxy::graphics::Font::Font ( )

Constructor.

Definition at line 18 of file Font.cpp.

◆ Font() [2/2]

galaxy::graphics::Font::Font ( Font && f)

Move constructor.

Definition at line 24 of file Font.cpp.

◆ ~Font()

galaxy::graphics::Font::~Font ( )

Destructor.

Definition at line 57 of file Font.cpp.

Member Function Documentation

◆ operator=()

Font & galaxy::graphics::Font::operator= ( Font && f)

Move assignment operator.

Definition at line 38 of file Font.cpp.

◆ load() [1/2]

bool galaxy::graphics::Font::load ( const std::string & file)
nodiscard

Loads the font and sets up characters.

Parameters
filePath to the font file.
Returns
True if successful.

Definition at line 67 of file Font.cpp.

+ Here is the caller graph for this function:

◆ load() [2/2]

bool galaxy::graphics::Font::load ( unsigned char * buffer,
const unsigned int size )
nodiscard

Loads the font and sets up characters.

Parameters
bufferArray of data.
sizeSize of buffer.
Returns
True if successful.

Definition at line 88 of file Font.cpp.

◆ build()

void galaxy::graphics::Font::build ( )

Build the font atlas.

Not thread safe, calls OpenGL code.

Definition at line 107 of file Font.cpp.

+ Here is the caller graph for this function:

◆ vertical_advance()

float galaxy::graphics::Font::vertical_advance ( const float size) const
nodiscard

Get vertical advance for drawing multiline text.

Parameters
sizeFont size in em.
Returns
Float.

Definition at line 125 of file Font.cpp.

+ Here is the caller graph for this function:

◆ get_text_size()

glm::vec2 galaxy::graphics::Font::get_text_size ( const std::string & text,
const float size )
nodiscard

Query text size with font.

Doesnt support vertical text. You also need to pre-process tab symbols.

Parameters
textText to query.
sizeFont size in em.
Returns
Vector 2 of dimensions of text.

Definition at line 130 of file Font.cpp.

+ Here is the caller graph for this function:

◆ handle()

msdfgl_font_t galaxy::graphics::Font::handle ( )
nodiscard

Get handle to internal font object.

Returns
msdfgl_font_t pointer.

Definition at line 170 of file Font.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_font

msdfgl_font_t galaxy::graphics::Font::m_font
private

Font object.

Definition at line 110 of file Font.hpp.

◆ m_face

FT_Face galaxy::graphics::Font::m_face
private

Freetype face.

Owned by MSDFGL.

Definition at line 117 of file Font.hpp.


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