Font
The ControlFont plugin converts Brep TrueType Font (TTF) files into a series of vector-based CanvasShape elements. It provides flexible methods to compose multiple CanvasShape objects from an input text string, enabling resolution-independent, high-quality text rendering. Multiple ControlFont instances can be organized hierarchically to share font data efficiently across CanvasFont instances, minimizing resource usage. The vector-based CanvasShape rendering is ideal for crisp, scalable text in 3D user interfaces and other graphics applications where resolution independence and transform flexibility are essential.
#include <interface/font/include/TellusimControlFont.h>
Example
// create font
ControlFont font(&grid);
// load a Brep TTF font file
font.loadFont("sansb.ttf");
// configure rendering mode and alignment
font.setMode(CanvasElement::ModeGradient);
font.setAlign(Control::AlignExpand | Control::AlignCenter | Control::AlignAspect);
// set radial gradient style from green to yellow
font.setGradientStyle(GradientStyle(1.25f, Vector2f(0.0f, 1.0f), Color::green, Color::yellow));
// update text dynamically with current time
uint64_t current_time = Time::current();
Date date(current_time / Time::Seconds);
uint32_t cseconds = (uint32_t)((current_time % Time::Seconds) / 10000);
font.setText(String::format("Tellusim SDK\nplugins/interface/font\n%s %02u", date.getString("HH:mm:ss").get(), cseconds));