idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
Font Component

Fixed-cell bitmap font model and text metrics. More...

Modules

 Spleen Fonts
 The Spleen 5x8 and 8x16 fixed-cell bitmap fonts.
 

Namespaces

namespace  idfxx
 
namespace  idfxx::font
 Bitmap font types, text metrics, and bundled fonts.
 

Classes

struct  idfxx::font::mono_font
 A fixed-cell monochrome bitmap font. More...
 

Functions

constexpr size_t idfxx::font::text_width (const mono_font &font, std::string_view text, unsigned scale=1) noexcept
 Returns the width in pixels of text rendered in font.
 

Detailed Description

Fixed-cell bitmap font model and text metrics.

Provides a compact fixed-cell font representation and text measurement. Rendering lives in the Graphics Component component; bundled fonts are published as separate data packages (e.g. idfxx_font_spleen), each font in its own translation unit so fonts an application never references are dropped at link time. A BDF-to-C converter script for adding more fonts is included under scripts/.

Function Documentation

◆ text_width()

constexpr size_t idfxx::font::text_width ( const mono_font font,
std::string_view  text,
unsigned  scale = 1 
)
constexprnoexcept

Returns the width in pixels of text rendered in font.

Sums the advance of every character in text; characters outside the font's glyph range advance like any other (rendered blank).

Parameters
fontThe font.
textThe text to measure.
scaleInteger magnification factor (>= 1; 0 is treated as 1).
Returns
The rendered width in pixels.

Definition at line 104 of file font.hpp.

References idfxx::font::mono_font::advance().