ESPHome 2025.12.1
Loading...
Searching...
No Matches
esphome::font::Font Class Reference

#include <font.h>

Inheritance diagram for esphome::font::Font:
esphome::display::BaseFont

Public Member Functions

 Font (const Glyph *data, int data_nr, int baseline, int height, int descender, int xheight, int capheight, uint8_t bpp=1)
 Construct the font with the given glyphs.
 
const Glyphfind_glyph (uint32_t codepoint) const
 
void print (int x_start, int y_start, display::Display *display, Color color, const char *text, Color background) override
 
void measure (const char *str, int *width, int *x_offset, int *baseline, int *height) override
 
int get_baseline ()
 
int get_height ()
 
int get_ascender ()
 
int get_descender ()
 
int get_linegap ()
 
int get_xheight ()
 
int get_capheight ()
 
int get_bpp ()
 
const lv_font_t * get_lv_font () const
 
const ConstVector< Glyph > & get_glyphs () const
 
- Public Member Functions inherited from esphome::display::BaseFont

Protected Member Functions

const Glyphget_glyph_data_ (uint32_t unicode_letter)
 

Static Protected Member Functions

static const uint8_t * get_glyph_bitmap (const lv_font_t *font, uint32_t unicode_letter)
 
static bool get_glyph_dsc_cb (const lv_font_t *font, lv_font_glyph_dsc_t *dsc, uint32_t unicode_letter, uint32_t next)
 

Protected Attributes

ConstVector< Glyphglyphs_
 
int baseline_
 
int height_
 
int descender_
 
int linegap_
 
int xheight_
 
int capheight_
 
uint8_t bpp_
 
lv_font_t lv_font_ {}
 
uint32_t last_letter_ {}
 
const Glyphlast_data_ {}
 

Detailed Description

Definition at line 41 of file font.h.

Constructor & Destructor Documentation

◆ Font()

esphome::font::Font::Font ( const Glyph * data,
int data_nr,
int baseline,
int height,
int descender,
int xheight,
int capheight,
uint8_t bpp = 1 )

Construct the font with the given glyphs.

Parameters
dataA list of glyphs, must be sorted lexicographically.
data_nrThe number of glyphs
baselineThe y-offset from the top of the text to the baseline.
heightThe y-offset from the top of the text to the bottom.
descenderThe y-offset from the baseline to the lowest stroke in the font (e.g. from letters like g or p).
xheightThe height of lowercase letters, usually measured at the "x" glyph.
capheightThe height of capital letters, usually measured at the "X" glyph.
bppThe bits per pixel used for this font. Used to read data out of the glyph bitmaps.

Definition at line 152 of file font.cpp.

Member Function Documentation

◆ find_glyph()

const Glyph * esphome::font::Font::find_glyph ( uint32_t codepoint) const

Definition at line 174 of file font.cpp.

◆ get_ascender()

int esphome::font::Font::get_ascender ( )
inline

Definition at line 70 of file font.h.

◆ get_baseline()

int esphome::font::Font::get_baseline ( )
inline

Definition at line 68 of file font.h.

◆ get_bpp()

int esphome::font::Font::get_bpp ( )
inline

Definition at line 75 of file font.h.

◆ get_capheight()

int esphome::font::Font::get_capheight ( )
inline

Definition at line 74 of file font.h.

◆ get_descender()

int esphome::font::Font::get_descender ( )
inline

Definition at line 71 of file font.h.

◆ get_glyph_bitmap()

const uint8_t * esphome::font::Font::get_glyph_bitmap ( const lv_font_t * font,
uint32_t unicode_letter )
staticprotected

Definition at line 12 of file font.cpp.

◆ get_glyph_data_()

const Glyph * esphome::font::Font::get_glyph_data_ ( uint32_t unicode_letter)
protected

Definition at line 37 of file font.cpp.

◆ get_glyph_dsc_cb()

bool esphome::font::Font::get_glyph_dsc_cb ( const lv_font_t * font,
lv_font_glyph_dsc_t * dsc,
uint32_t unicode_letter,
uint32_t next )
staticprotected

Definition at line 21 of file font.cpp.

◆ get_glyphs()

const ConstVector< Glyph > & esphome::font::Font::get_glyphs ( ) const
inline

Definition at line 80 of file font.h.

◆ get_height()

int esphome::font::Font::get_height ( )
inline

Definition at line 69 of file font.h.

◆ get_linegap()

int esphome::font::Font::get_linegap ( )
inline

Definition at line 72 of file font.h.

◆ get_lv_font()

const lv_font_t * esphome::font::Font::get_lv_font ( ) const
inline

Definition at line 77 of file font.h.

◆ get_xheight()

int esphome::font::Font::get_xheight ( )
inline

Definition at line 73 of file font.h.

◆ measure()

void esphome::font::Font::measure ( const char * str,
int * width,
int * x_offset,
int * baseline,
int * height )
overridevirtual

Implements esphome::display::BaseFont.

Definition at line 192 of file font.cpp.

◆ print()

void esphome::font::Font::print ( int x_start,
int y_start,
display::Display * display,
Color color,
const char * text,
Color background )
overridevirtual

Implements esphome::display::BaseFont.

Definition at line 225 of file font.cpp.

Field Documentation

◆ baseline_

int esphome::font::Font::baseline_
protected

Definition at line 84 of file font.h.

◆ bpp_

uint8_t esphome::font::Font::bpp_
protected

Definition at line 90 of file font.h.

◆ capheight_

int esphome::font::Font::capheight_
protected

Definition at line 89 of file font.h.

◆ descender_

int esphome::font::Font::descender_
protected

Definition at line 86 of file font.h.

◆ glyphs_

ConstVector<Glyph> esphome::font::Font::glyphs_
protected

Definition at line 83 of file font.h.

◆ height_

int esphome::font::Font::height_
protected

Definition at line 85 of file font.h.

◆ last_data_

const Glyph* esphome::font::Font::last_data_ {}
protected

Definition at line 97 of file font.h.

◆ last_letter_

uint32_t esphome::font::Font::last_letter_ {}
protected

Definition at line 96 of file font.h.

◆ linegap_

int esphome::font::Font::linegap_
protected

Definition at line 87 of file font.h.

◆ lv_font_

lv_font_t esphome::font::Font::lv_font_ {}
protected

Definition at line 92 of file font.h.

◆ xheight_

int esphome::font::Font::xheight_
protected

Definition at line 88 of file font.h.


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