lv_text_private.h
API reference for lv_text_private.h
Functions
lv_text_set_text_vfmt
Return a new formatted text. Memory will be allocated to store the text.
char * lv_text_set_text_vfmt(const char *fmt, va_list ap)| Name | Type | Description |
|---|---|---|
fmt | const char * | printf-like format |
ap | va_list | items to print |
Returns: char * — pointer to the allocated text string.
lv_text_get_size_attributes
Get size of a text
void lv_text_get_size_attributes(lv_point_t *size_res, const char *text, const lv_font_t *font, lv_text_attributes_t *attributes)| Name | Type | Description |
|---|---|---|
size_res | lv_point_t * | pointer to a 'point_t' variable to store the result |
text | const char * | pointer to a text |
font | const lv_font_t * | pointer to font of the text |
attributes | lv_text_attributes_t * | the text attributes, flags for line break behaviour, spacing etc |
lv_text_get_width
Give the length of a text with a given font with text flags
int32_t lv_text_get_width(const char *txt, uint32_t length, const lv_font_t *font, const lv_text_attributes_t *attributes)| Name | Type | Description |
|---|---|---|
txt | const char * | a '\0' terminate string |
length | uint32_t | length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8) |
font | const lv_font_t * | pointer to font of the text |
attributes | const lv_text_attributes_t * | the text attributes, flags for line break behaviour, spacing etc |
Returns: int32_t — length of a char_num long text
lv_text_get_line_width
Same as lv_text_get_width() but without the trailing white space of the line.
int32_t lv_text_get_line_width(const char *txt, uint32_t length, const lv_font_t *font, const lv_text_attributes_t *attributes)| Name | Type | Description |
|---|---|---|
txt | const char * | a '\0' terminate string |
length | uint32_t | length of 'txt' in byte count and not characters |
font | const lv_font_t * | pointer to font of the text |
attributes | const lv_text_attributes_t * | the text attributes, flags for line break behaviour, spacing etc |
Returns: int32_t — visible width of the line
lv_text_get_next_line
Get the next line of text. Check line length and break chars too.
uint32_t lv_text_get_next_line(const char *txt, uint32_t len, const lv_font_t *font, int32_t *used_width, lv_text_attributes_t *attributes)| Name | Type | Description |
|---|---|---|
txt | const char * | a '\0' terminated string |
len | uint32_t | length of 'txt' in bytes |
font | const lv_font_t * | pointer to a font |
used_width | int32_t * | When used_width != NULL, save the width of this line if flag == LV_TEXT_FLAG_NONE, otherwise save -1. |
attributes | lv_text_attributes_t * | text attributes, flags to control line break behaviour, spacing etc |
Returns: uint32_t — the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
lv_text_get_size_internal
Internal implementation of lv_text_get_size
void lv_text_get_size_internal(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)| Name | Type |
|---|---|
size_res | lv_point_t * |
text | const char * |
font | const lv_font_t * |
letter_space | int32_t |
line_space | int32_t |
max_width | int32_t |
flag | lv_text_flag_t |
lv_font_get_bottom_trim_internal
static int32_t lv_font_get_bottom_trim_internal(const lv_font_t *font, lv_text_leading_trim_t trim)| Name | Type |
|---|---|
font | const lv_font_t * |
trim | lv_text_leading_trim_t |
lv_font_get_top_trim_internal
static int32_t lv_font_get_top_trim_internal(const lv_font_t *font, lv_text_leading_trim_t trim)| Name | Type |
|---|---|
font | const lv_font_t * |
trim | lv_text_leading_trim_t |
lv_text_attributes_init
Initialize the text attributes descriptor
void lv_text_attributes_init(lv_text_attributes_t *attributes)| Name | Type | Description |
|---|---|---|
attributes | lv_text_attributes_t * | the text attributes descriptor to initialize |
lv_text_is_cmd
Check if c is command state
bool lv_text_is_cmd(lv_text_cmd_state_t *state, uint32_t c)| Name | Type |
|---|---|
state | lv_text_cmd_state_t * |
c | uint32_t |
Returns: bool — True if c is state
lv_text_ins
Insert a string into another
void lv_text_ins(char *txt_buf, uint32_t pos, const char *ins_txt)| Name | Type | Description |
|---|---|---|
txt_buf | char * | the original text (must be big enough for the result text and NULL terminated) |
pos | uint32_t | position to insert (0: before the original text, 1: after the first char etc.) |
ins_txt | const char * | text to insert, must be '\0' terminated |
lv_text_cut
Delete a part of a string
void lv_text_cut(char *txt, uint32_t pos, uint32_t len)| Name | Type | Description |
|---|---|---|
txt | char * | string to modify, must be '\0' terminated and should point to a heap or stack frame, not read-only memory. |
pos | uint32_t | position where to start the deleting (0: before the first char, 1: after the first char etc.) |
len | uint32_t | number of characters to delete |
lv_text_encoded_letter_next_2
Decode two encoded character from a string.
void lv_text_encoded_letter_next_2(const char *txt, uint32_t *letter, uint32_t *letter_next, uint32_t *ofs)| Name | Type | Description |
|---|---|---|
txt | const char * | pointer to '\0' terminated string |
letter | uint32_t * | the first decoded Unicode character or 0 on invalid data code |
letter_next | uint32_t * | the second decoded Unicode character or 0 on invalid data code |
ofs | uint32_t * | start index in 'txt' where to start. After the call it will point to the next encoded char in 'txt'. NULL to use txt[0] as index |
lv_text_is_break_char
Test if char is break char or not (a text can broken here or not)
static bool lv_text_is_break_char(uint32_t letter)| Name | Type | Description |
|---|---|---|
letter | uint32_t | a letter |
Returns: bool — false: 'letter' is not break char
lv_text_is_hanging_space
Test if char is white space which may hang out of the end of a line
static bool lv_text_is_hanging_space(uint32_t letter)| Name | Type | Description |
|---|---|---|
letter | uint32_t | a letter |
Returns: bool — false: 'letter' is not hangable white space
lv_text_is_a_word
Test if char is break char or not (a text can broken here or not)
static bool lv_text_is_a_word(uint32_t letter)| Name | Type | Description |
|---|---|---|
letter | uint32_t | a letter |
Returns: bool — false: 'letter' is not break char
lv_text_is_marker
Test if character can be treated as marker, and don't need to be rendered. Note, this is not a full list. Add your findings to the list.
static bool lv_text_is_marker(uint32_t letter)| Name | Type | Description |
|---|---|---|
letter | uint32_t | a letter |
Returns: bool — true if so
Enums
lv_text_cmd_state_t
State machine for text renderer.
| Name | Description |
|---|---|
LV_TEXT_CMD_STATE_WAIT | Waiting for command |
LV_TEXT_CMD_STATE_PAR | Processing the parameter |
LV_TEXT_CMD_STATE_IN | Processing the command |
Used by 1 function
lv_text_is_cmd— paramstate
Structs
lv_text_attributes_t
| Member | Type | Description |
|---|---|---|
letter_space | int32_t | Letter space between letters |
line_space | int32_t | Space between lines of text |
max_width | int32_t | Max width of the text (break the lines to fit this size). Set COORD_MAX to avoid |
text_flags | lv_text_flag_t |
Used by 5 functions
lv_text_attributes_init— paramattributeslv_text_get_size_attributes— paramattributeslv_text_get_width— paramattributeslv_text_get_line_width— paramattributeslv_text_get_next_line— paramattributes
Macros
LV_TXT_ENC_UTF8
#define LV_TXT_ENC_UTF8 1LV_TXT_ENC_ASCII
#define LV_TXT_ENC_ASCII 2LV_TEXT_LEN_MAX
#define LV_TEXT_LEN_MAX UINT32_MAXVariables
lv_text_encoded_size
uint8_t(*const lv_text_encoded_sizeGive the size of an encoded character
lv_text_unicode_to_encoded
uint32_t(*const lv_text_unicode_to_encodedConvert a Unicode letter to encoded
lv_text_encoded_conv_wc
uint32_t(*const lv_text_encoded_conv_wcConvert a wide character, e.g. 'Á' little endian to be compatible with the encoded format.
lv_text_encoded_next
uint32_t(*const lv_text_encoded_nextDecode the next encoded character from a string.
lv_text_encoded_prev
uint32_t(*const lv_text_encoded_prevGet the previous encoded character form a string.
lv_text_encoded_get_byte_id
uint32_t(*const lv_text_encoded_get_byte_idConvert a letter index (in the encoded text) to byte index. E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
lv_text_encoded_get_char_id
uint32_t(*const lv_text_encoded_get_char_idConvert a byte index (in an encoded text) to character index. E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long
lv_text_get_encoded_length
uint32_t(*const lv_text_get_encoded_lengthGet the number of characters (and NOT bytes) in a string. E.g. in UTF-8 "ÁBC" is 3 characters (but 4 bytes)
Dependencies
lvgl_public.h
Last updated on