Image font (imgfont)

Draw image in label or span obj with imgfont. This is often used to display Unicode emoji icons in text. Supported image formats: determined by LVGL image decoder.

Usage

Enable LV_USE_IMGFONT in lv_conf.h.

To create a new imgfont use lv_imgfont_create(height, path_cb).

height used to indicate the size of a imgfont. path_cb Used to get the image path of the specified unicode.

Use lv_imgfont_destroy(imgfont) to destroy a imgfont that is no longer used.

Example

Use emojis in a text.

C code  

 GitHub

MicroPython code  

 GitHub Simulator

API

Typedefs

typedef bool (*lv_get_imgfont_path_cb_t)(const lv_font_t *font, void *img_src, uint16_t len, uint32_t unicode, uint32_t unicode_next)

Functions

lv_font_t *lv_imgfont_create(uint16_t height, lv_get_imgfont_path_cb_t path_cb)

Creates a image font with info parameter specified.

Parameters
  • height -- font size

  • path_cb -- a function to get the image path name of character.

Returns

pointer to the new imgfont or NULL if create error.

void lv_imgfont_destroy(lv_font_t *font)

Destroy a image font that has been created.

Parameters

font -- pointer to image font handle.