Skip to main content

Font

The Font class provides functionality for loading, managing, and rendering fonts, supporting multiple font styles and sizes. It allows checking if a font is loaded, retrieving glyph advances, and calculating text bounding rectangles for both single and batched text. The class supports creating and drawing text using a specified font style, either character by character or in batches.

#include <interface/TellusimFont.h>

Constructors

Font()

Methods

Clear font.

void clear()

Check font.

bool isLoaded() const

Load font.

bool load(const char *name)
bool load(Stream &stream)

Glyph advance.

float32_t getAdvance(FontStyle style, uint32_t code)

Text rectangle.

Rect getRect(Vector3f position, FontStyle style, const char *str)
Rect getRect(Vector3f position, FontStyle style, const uint32_t *str)
template<> Rect getRect(const Vector3f &position, uint32_t size, const Type *str)

Batched text rectangle.

Rect getRect(const FontBatch *batches, uint32_t num_batches)
Rect getRect(const FontBatch32 *batches, uint32_t num_batches)

Create text.

void create(const Device &device, FontStyle style, const char *str)
void create(const Device &device, FontStyle style, const uint32_t *str)
template<> void create(const Device &device, uint32_t size, const Type *str)

Create batched text.

void create(const Device &device, const FontBatch *batches, uint32_t num_batches)
void create(const Device &device, const FontBatch32 *batches, uint32_t num_batches)

Draw text.

void draw(Command &command, Vector3f position, FontStyle style, const char *str)
void draw(Command &command, Vector3f position, FontStyle style, const uint32_t *str)
template<> void draw(Command *command, const Vector3f &position, uint32_t size, const Type *str)
template<> void draw(Command *command, const Vector3f &position, uint32_t size, const Color &color, const Type *str)

Draw batched text.

void draw(Command &command, const FontBatch *batches, uint32_t num_batches)
void draw(Command &command, const FontBatch32 *batches, uint32_t num_batches)

Flush textures.

bool flush(const Device &device)