lv_font.h

Defines

LV_IMGFONT_BPP
LV_FONT_DECLARE(font_name)

Typedefs

typedef _lv_font_subpx_t lv_font_subpx_t
typedef struct _lv_font_t lv_font_t

Describe the properties of a font

Enums

enum _lv_font_subpx_t

The bitmaps might be upscaled by 3 to achieve subpixel rendering.

Values:

enumerator LV_FONT_SUBPX_NONE
enumerator LV_FONT_SUBPX_HOR
enumerator LV_FONT_SUBPX_VER
enumerator LV_FONT_SUBPX_BOTH

Functions

const uint8_t *lv_font_get_glyph_bitmap(const lv_font_t *font, uint32_t letter, uint8_t *buf_out)

Return with the bitmap of a font.

Parameters:
  • font_p -- pointer to a font

  • letter -- a UNICODE character code

Returns:

pointer to the bitmap of the letter

bool lv_font_get_glyph_dsc(const lv_font_t *font, lv_font_glyph_dsc_t *dsc_out, uint32_t letter, uint32_t letter_next)

Get the descriptor of a glyph

Parameters:
  • font -- pointer to font

  • dsc_out -- store the result descriptor here

  • letter -- a UNICODE letter code

  • letter_next -- the next letter after letter. Used for kerning

Returns:

true: descriptor is successfully loaded into dsc_out. false: the letter was not found, no data is loaded to dsc_out

uint16_t lv_font_get_glyph_width(const lv_font_t *font, uint32_t letter, uint32_t letter_next)

Get the width of a glyph with kerning

Parameters:
  • font -- pointer to a font

  • letter -- a UNICODE letter

  • letter_next -- the next letter after letter. Used for kerning

Returns:

the width of the glyph

static inline lv_coord_t lv_font_get_line_height(const lv_font_t *font)

Get the line height of a font. All characters fit into this height

Parameters:

font -- pointer to a font

Returns:

the height of a font

static inline const lv_font_t *lv_font_default(void)

Just a wrapper around LV_FONT_DEFAULT because it might be more convenient to use a function in some cases

Returns:

pointer to LV_FONT_DEFAULT

Variables

const lv_font_t lv_font_montserrat_14
struct lv_font_glyph_dsc_t
#include <lv_font.h>

Describes the properties of a glyph.

Public Members

const struct _lv_font_t *resolved_font

Pointer to a font where the glyph was actually found after handling fallbacks

uint16_t adv_w

The glyph needs this space. Draw the next glyph after this width.

uint16_t box_w

Width of the glyph's bounding box

uint16_t box_h

Height of the glyph's bounding box

int16_t ofs_x

x offset of the bounding box

int16_t ofs_y

y offset of the bounding box

uint8_t bpp

Bit-per-pixel: 1, 2, 4, 8

uint8_t is_placeholder
struct _lv_font_t
#include <lv_font.h>

Describe the properties of a font

Public Members

bool (*get_glyph_dsc)(const struct _lv_font_t*, lv_font_glyph_dsc_t*, uint32_t letter, uint32_t letter_next)

Get a glyph's descriptor from a font

const uint8_t *(*get_glyph_bitmap)(const struct _lv_font_t*, uint32_t, uint8_t*)

Get a glyph's bitmap from a font

lv_coord_t line_height

The real line height where any text fits

lv_coord_t base_line

Base line measured from the top of the line_height

uint8_t subpx

An element of lv_font_subpx_t

int8_t underline_position

Distance between the top of the underline and base line (< 0 means below the base line)

int8_t underline_thickness

Thickness of the underline

const void *dsc

Store implementation specific or run_time data or caching here

const struct _lv_font_t *fallback

Fallback font for missing glyph. Resolved recursively

void *user_data

Custom user data for font.