lv_text.h

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.

enumerator LV_TEXT_FLAG_RECOLOR

Enable parsing of recolor command

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

enum lv_text_leading_trim_t

Text leading trim mode (similar to CSS text-box-trim / text-box-edge) using more intuitive naming. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-box-edge

Values:

enumerator LV_TEXT_LEADING_TRIM_NONE

No trimming (default behavior)

enumerator LV_TEXT_LEADING_TRIM_CAPITAL_BASELINE

Trim to the top of the capital letters (cap height) and the bottom to the (alphabetic) baseline

enumerator LV_TEXT_LEADING_TRIM_LOWER_BASELINE

Trim to the top of the lower case letters (x-height) and the bottom to the (alphabetic) baseline Trim only the top to the height of the capital letters (cap-height)

enumerator LV_TEXT_LEADING_TRIM_CAPITAL

Trim only the top to the height of the lower case letters (x-height)

enumerator LV_TEXT_LEADING_TRIM_LOWER

Functions

static inline int32_t lv_font_get_top_trim(const lv_font_t *font, lv_text_leading_trim_t trim)

Get the number of pixels to trim from the top of text for a given leading-trim mode.

Parameters:
  • font – pointer to a font

  • trim – leading-trim mode

Returns:

pixels to trim from the top (0 if no trimming)

static inline int32_t lv_font_get_bottom_trim(const lv_font_t *font, lv_text_leading_trim_t trim)

Get the number of pixels to trim from the bottom of text for a given leading-trim mode.

Parameters:
  • font – pointer to a font

  • trim – leading-trim mode

Returns:

pixels to trim from the bottom (0 if no trimming)

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

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