lv_text.h

Defines

LV_TXT_ENC_UTF8
LV_TXT_ENC_ASCII

Enums

enum lv_text_flag_t

Options for text rendering.

Values:

enumerator LV_TEXT_FLAG_NONE
enumerator LV_TEXT_FLAG_EXPAND

Ignore max-width to avoid automatic word wrapping

enumerator LV_TEXT_FLAG_FIT

Max-width is already equal to the longest line. (Used to skip some calculation)

enumerator LV_TEXT_FLAG_BREAK_ALL

To prevent overflow, insert breaks between any two characters. Otherwise breaks are inserted at word boundaries, as configured via LV_TXT_BREAK_CHARS or according to LV_TXT_LINE_BREAK_LONG_LEN, LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN, and LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN.

enum lv_text_align_t

Label align policy

Values:

enumerator LV_TEXT_ALIGN_AUTO

Align text auto

enumerator LV_TEXT_ALIGN_LEFT

Align text to left

enumerator LV_TEXT_ALIGN_CENTER

Align text to center

enumerator LV_TEXT_ALIGN_RIGHT

Align text to right

Functions

void lv_text_get_size(lv_point_t *size_res, const char *text, const lv_font_t *font, int32_t letter_space, int32_t line_space, int32_t max_width, lv_text_flag_t flag)

Get size of a text

line breaks

Parameters:
  • size_res -- pointer to a 'point_t' variable to store the result

  • text -- pointer to a text

  • font -- pointer to font of the text

  • letter_space -- letter space of the text

  • line_space -- line space of the text

  • max_width -- max width of the text (break the lines to fit this size). Set COORD_MAX to avoid

  • flag -- settings for the text from lv_text_flag_t

int32_t lv_text_get_width(const char *txt, uint32_t length, const lv_font_t *font, int32_t letter_space)

Give the length of a text with a given font

Parameters:
  • txt -- a '\0' terminate string

  • length -- length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8)

  • font -- pointer to a font

  • letter_space -- letter space

Returns:

length of a char_num long text