Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
TextRenderer Class Reference

Central wrapper for all GUI text. Owns one shared Font (JetBrainsMono) loaded once for the window lifetime; falls back to GetFontDefault() if unloaded. More...

#include <TextRenderer.hpp>

+ Collaboration diagram for TextRenderer:

Static Public Member Functions

static bool loadFont (const std::string &path)
 
static void unloadFont ()
 
static void draw (const std::string &text, int x, int y, int fontSize, Color color)
 
static int measure (const std::string &text, int fontSize)
 

Static Private Member Functions

static float _spacing (int fontSize)
 
static const Font & _active ()
 

Static Private Attributes

static Font _font = {}
 
static bool _loaded = false
 
static constexpr int BASE_SIZE
 

Detailed Description

Central wrapper for all GUI text. Owns one shared Font (JetBrainsMono) loaded once for the window lifetime; falls back to GetFontDefault() if unloaded.

Definition at line 11 of file TextRenderer.hpp.

Member Function Documentation

◆ _active()

const Font & TextRenderer::_active ( )
staticprivate

Definition at line 13 of file TextRenderer.cpp.

References _font, and _loaded.

Referenced by draw(), and measure().

+ Here is the caller graph for this function:

◆ _spacing()

float TextRenderer::_spacing ( int  fontSize)
staticprivate

Definition at line 8 of file TextRenderer.cpp.

Referenced by draw(), and measure().

+ Here is the caller graph for this function:

◆ draw()

void TextRenderer::draw ( const std::string &  text,
int  x,
int  y,
int  fontSize,
Color  color 
)
static

Definition at line 52 of file TextRenderer.cpp.

References _active(), and _spacing().

Referenced by ButtonWidget::draw(), SpeedSlider::draw(), TooltipWidget::draw(), and TooltipRenderer::Builder::draw().

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

◆ loadFont()

bool TextRenderer::loadFont ( const std::string &  path)
static

Definition at line 30 of file TextRenderer.cpp.

References _buildCodepoints(), _font, _loaded, BASE_SIZE, and unloadFont().

Referenced by RaylibRenderer::init().

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

◆ measure()

int TextRenderer::measure ( const std::string &  text,
int  fontSize 
)
static

Definition at line 59 of file TextRenderer.cpp.

References _active(), and _spacing().

Referenced by EntityTooltipWidget::_positionButton(), ButtonWidget::draw(), TooltipWidget::draw(), and TooltipRenderer::Builder::draw().

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

◆ unloadFont()

void TextRenderer::unloadFont ( )
static

Definition at line 44 of file TextRenderer.cpp.

References _font, and _loaded.

Referenced by loadFont(), and RaylibRenderer::shutdown().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _font

Font TextRenderer::_font = {}
staticprivate

Definition at line 5 of file TextRenderer.hpp.

Referenced by _active(), loadFont(), and unloadFont().

◆ _loaded

bool TextRenderer::_loaded = false
staticprivate

Definition at line 21 of file TextRenderer.hpp.

Referenced by _active(), loadFont(), and unloadFont().

◆ BASE_SIZE

constexpr int TextRenderer::BASE_SIZE
staticconstexprprivate
Initial value:
=
32

Definition at line 23 of file TextRenderer.hpp.

Referenced by loadFont().


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