lv_text.h

API reference for lv_text.h

Report on GitHub
See Also: Private HeaderThis header has a companion private implementation with internal data structures.lv_text_private.h

Functions

lv_font_get_top_trim

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

 
static int32_t lv_font_get_top_trim(const lv_font_t *font, lv_text_leading_trim_t trim)
Parameters
NameTypeDescription
fontconst lv_font_t *pointer to a font
trimlv_text_leading_trim_tleading-trim mode

Returns: int32_t — pixels to trim from the top (0 if no trimming)

lv_font_get_bottom_trim

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

 
static int32_t lv_font_get_bottom_trim(const lv_font_t *font, lv_text_leading_trim_t trim)
Parameters
NameTypeDescription
fontconst lv_font_t *pointer to a font
trimlv_text_leading_trim_tleading-trim mode

Returns: int32_t — pixels to trim from the bottom (0 if no trimming)

lv_text_get_size

Get size of a text

 
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)
Parameters
NameTypeDescription
size_reslv_point_t *pointer to a 'point_t' variable to store the result
textconst char *pointer to a text
fontconst lv_font_t *pointer to font of the text
letter_spaceint32_tletter space of the text
line_spaceint32_tline space of the text
max_widthint32_tmax width of the text (break the lines to fit this size). Set COORD_MAX to avoid
flaglv_text_flag_tsettings for the text from lv_text_flag_t

Enums

lv_text_flag_t

Options for text rendering.

NameValueDescription
LV_TEXT_FLAG_NONE0x00
LV_TEXT_FLAG_EXPAND0x01Ignore max-width to avoid automatic word wrapping
LV_TEXT_FLAG_FIT0x02Max-width is already equal to the longest line. (Used to skip some calculation)
LV_TEXT_FLAG_BREAK_ALL0x04To 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.
LV_TEXT_FLAG_RECOLOR0x08Enable parsing of recolor command
Used by 1 function
  • lv_text_get_size — param flag

lv_text_align_t

Label align policy

NameDescription
LV_TEXT_ALIGN_AUTOAlign text auto
LV_TEXT_ALIGN_LEFTAlign text to left
LV_TEXT_ALIGN_CENTERAlign text to center
LV_TEXT_ALIGN_RIGHTAlign text to right
Used by 5 functions
  • lv_obj_set_style_text_align — param value
  • lv_bidi_calculate_align — param align
  • lv_style_set_text_align — param value
  • lv_spangroup_set_align — param align
  • lv_textarea_set_align — param align

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

NameValueDescription
LV_TEXT_LEADING_TRIM_NONE0No trimming (default behavior)
LV_TEXT_LEADING_TRIM_CAPITAL_BASELINETrim to the top of the capital letters (cap height) and the bottom to the (alphabetic) baseline
LV_TEXT_LEADING_TRIM_LOWER_BASELINETrim 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)
LV_TEXT_LEADING_TRIM_CAPITALTrim only the top to the height of the lower case letters (x-height)
LV_TEXT_LEADING_TRIM_LOWER
Used by 4 functions
  • lv_obj_set_style_text_leading_trim — param value
  • lv_style_set_text_leading_trim — param value
  • lv_font_get_top_trim — param trim
  • lv_font_get_bottom_trim — param trim

Dependencies

How is this guide?

Last updated on

On this page