Josh's Graphics Library
JGL::Font Class Reference

A Font class implementation. More...

#include <Font.h>

Public Member Functions

 Font ()=default
 Default constructor does not initialize any members. More...
 
 Font (const std::filesystem::path &path)
 
 ~Font ()
 Destructor handles freeing of the underlying asset handle. More...
 
Vector2 MeasureString (const std::string &text, unsigned int ptSize)
 Returns the bounding-box the given string would occupy at the given point-size, assuming normal (1) scaling. More...
 

Static Public Member Functions

static Font LoadTTF (const std::filesystem::path &filepath)
 
static std::vector< FontGetLoadedFonts ()
 

Public Attributes

int index = 0
 
FT_Face face
 

Detailed Description

A Font class implementation.

Wraps the font's FreeType asset handle and provides helper functions.

Constructor & Destructor Documentation

◆ Font() [1/2]

JGL::Font::Font ( )
default

Default constructor does not initialize any members.

Here is the caller graph for this function:

◆ Font() [2/2]

JGL::Font::Font ( const std::filesystem::path &  path)

◆ ~Font()

JGL::Font::~Font ( )

Destructor handles freeing of the underlying asset handle.

Member Function Documentation

◆ GetLoadedFonts()

std::vector< Font > JGL::Font::GetLoadedFonts ( )
static

◆ LoadTTF()

Font JGL::Font::LoadTTF ( const std::filesystem::path &  filepath)
static
Here is the call graph for this function:

◆ MeasureString()

Vector2 JGL::Font::MeasureString ( const std::string &  text,
unsigned int  ptSize 
)

Returns the bounding-box the given string would occupy at the given point-size, assuming normal (1) scaling.

Parameters
textThe string to measure.
ptSizeThe font size at which to measure.
Returns
The size-in-pixels that would contain the entire text.
Here is the call graph for this function:

Member Data Documentation

◆ face

FT_Face JGL::Font::face

◆ index

int JGL::Font::index = 0

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