# lv_text_private.h (/api/misc/lv_text_private_h)



<RelatedHeaders name="lv_text.h" isPrivate="true" />

<ApiSummary functions="12" enums="1" structs="1" macros="3" variables="8" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (1)&#x22;,&#x22;Getters (3)&#x22;,&#x22;Other (8)&#x22;]">
  <ApiTab value="Setters (1)">
    <ApiMember kind="function" name="lv_text_set_text_vfmt" file="misc/lv_text_private.h" line="128" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L128">
      lv_text_set_text_vfmt [#lv_text_set_text_vfmt]

      Return a new formatted text. Memory will be allocated to store the text.

      ```c title=" " lineNumbers=1
      char * lv_text_set_text_vfmt(const char *fmt, va_list ap)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type           | Description          |
      | ----- | -------------- | -------------------- |
      | `fmt` | `const char *` | `printf`-like format |
      | `ap`  | `va_list`      | items to print       |

      **Returns:** `char *` — pointer to the allocated text string.
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (3)">
    <ApiMember kind="function" name="lv_text_get_size_attributes" file="misc/lv_text_private.h" line="68" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L68">
      lv_text_get_size_attributes [#lv_text_get_size_attributes]

      Get size of a text

      ```c title=" " lineNumbers=1
      void lv_text_get_size_attributes(lv_point_t *size_res, const char *text, const lv_font_t *font, lv_text_attributes_t *attributes)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name         | Type                                                                     | Description                                                      |
      | ------------ | ------------------------------------------------------------------------ | ---------------------------------------------------------------- |
      | `size_res`   | <ApiLink name="lv_point_t" display="lv_point_t *" />                     | pointer to a 'point\_t' variable to store the result             |
      | `text`       | `const char *`                                                           | pointer to a text                                                |
      | `font`       | <ApiLink name="lv_font_t" display="const lv_font_t *" />                 | pointer to font of the text                                      |
      | `attributes` | <ApiLink name="lv_text_attributes_t" display="lv_text_attributes_t *" /> | the text attributes, flags for line break behaviour, spacing etc |
    </ApiMember>

    <ApiMember kind="function" name="lv_text_get_width" file="misc/lv_text_private.h" line="79" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L79">
      lv_text_get_width [#lv_text_get_width]

      Give the length of a text with a given font with text flags

      ```c title=" " lineNumbers=1
      int32_t lv_text_get_width(const char *txt, uint32_t length, const lv_font_t *font, const lv_text_attributes_t *attributes)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name         | Type                                                                           | Description                                                                              |
      | ------------ | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
      | `txt`        | `const char *`                                                                 | a '\0' terminate string                                                                  |
      | `length`     | <ApiLink name="uint32_t" />                                                    | length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8) |
      | `font`       | <ApiLink name="lv_font_t" display="const lv_font_t *" />                       | pointer to font of the text                                                              |
      | `attributes` | <ApiLink name="lv_text_attributes_t" display="const lv_text_attributes_t *" /> | the text attributes, flags for line break behaviour, spacing etc                         |

      **Returns:** <ApiLink name="int32_t" /> — length of a char\_num long text
    </ApiMember>

    <ApiMember kind="function" name="lv_text_get_next_line" file="misc/lv_text_private.h" line="101" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L101">
      lv_text_get_next_line [#lv_text_get_next_line]

      Get the next line of text. Check line length and break chars too.

      ```c title=" " lineNumbers=1
      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)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name         | Type                                                                     | Description                                                                                               |
      | ------------ | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
      | `txt`        | `const char *`                                                           | a '\0' terminated string                                                                                  |
      | `len`        | <ApiLink name="uint32_t" />                                              | length of 'txt' in bytes                                                                                  |
      | `font`       | <ApiLink name="lv_font_t" display="const lv_font_t *" />                 | pointer to a font                                                                                         |
      | `used_width` | <ApiLink name="int32_t" display="int32_t *" />                           | When used\_width != NULL, save the width of this line if flag == LV\_TEXT\_FLAG\_NONE, otherwise save -1. |
      | `attributes` | <ApiLink name="lv_text_attributes_t" display="lv_text_attributes_t *" /> | text attributes, flags to control line break behaviour, spacing etc                                       |

      **Returns:** <ApiLink name="uint32_t" /> — the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (8)">
    <ApiMember kind="function" name="lv_text_attributes_init" file="misc/lv_text_private.h" line="59" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L59">
      lv_text_attributes_init [#lv_text_attributes_init]

      Initialize the text attributes descriptor

      ```c title=" " lineNumbers=1
      void lv_text_attributes_init(lv_text_attributes_t *attributes)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name         | Type                                                                     | Description                                  |
      | ------------ | ------------------------------------------------------------------------ | -------------------------------------------- |
      | `attributes` | <ApiLink name="lv_text_attributes_t" display="lv_text_attributes_t *" /> | the text attributes descriptor to initialize |
    </ApiMember>

    <ApiMember kind="function" name="lv_text_is_cmd" file="misc/lv_text_private.h" line="88" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L88">
      lv_text_is_cmd [#lv_text_is_cmd]

      Check if c is command state

      ```c title=" " lineNumbers=1
      bool lv_text_is_cmd(lv_text_cmd_state_t *state, uint32_t c)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                                                   |
      | ------- | ---------------------------------------------------------------------- |
      | `state` | <ApiLink name="lv_text_cmd_state_t" display="lv_text_cmd_state_t *" /> |
      | `c`     | <ApiLink name="uint32_t" />                                            |

      **Returns:** <ApiLink name="bool" /> — True if c is state
    </ApiMember>

    <ApiMember kind="function" name="lv_text_ins" file="misc/lv_text_private.h" line="110" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L110">
      lv_text_ins [#lv_text_ins]

      Insert a string into another

      ```c title=" " lineNumbers=1
      void lv_text_ins(char *txt_buf, uint32_t pos, const char *ins_txt)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                        | Description                                                                    |
      | --------- | --------------------------- | ------------------------------------------------------------------------------ |
      | `txt_buf` | `char *`                    | the original text (must be big enough for the result text and NULL terminated) |
      | `pos`     | <ApiLink name="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                                        |
    </ApiMember>

    <ApiMember kind="function" name="lv_text_cut" file="misc/lv_text_private.h" line="119" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L119">
      lv_text_cut [#lv_text_cut]

      Delete a part of a string

      ```c title=" " lineNumbers=1
      void lv_text_cut(char *txt, uint32_t pos, uint32_t len)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | 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` | <ApiLink name="uint32_t" /> | position where to start the deleting (0: before the first char, 1: after the first char etc.)              |
      | `len` | <ApiLink name="uint32_t" /> | number of characters to delete                                                                             |
    </ApiMember>

    <ApiMember kind="function" name="lv_text_encoded_letter_next_2" file="misc/lv_text_private.h" line="139" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L139">
      lv_text_encoded_letter_next_2 [#lv_text_encoded_letter_next_2]

      Decode two encoded character from a string.

      ```c title=" " lineNumbers=1
      void lv_text_encoded_letter_next_2(const char *txt, uint32_t *letter, uint32_t *letter_next, uint32_t *ofs)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name          | Type                                             | Description                                                                                                                       |
      | ------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
      | `txt`         | `const char *`                                   | pointer to '\0' terminated string                                                                                                 |
      | `letter`      | <ApiLink name="uint32_t" display="uint32_t *" /> | the first decoded Unicode character or 0 on invalid data code                                                                     |
      | `letter_next` | <ApiLink name="uint32_t" display="uint32_t *" /> | the second decoded Unicode character or 0 on invalid data code                                                                    |
      | `ofs`         | <ApiLink name="uint32_t" display="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 |
    </ApiMember>

    <ApiMember kind="function" name="lv_text_is_break_char" file="misc/lv_text_private.h" line="146" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L146">
      lv_text_is_break_char [#lv_text_is_break_char]

      Test if char is break char or not (a text can broken here or not)

      ```c title=" " lineNumbers=1
      static bool lv_text_is_break_char(uint32_t letter)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                        | Description |
      | -------- | --------------------------- | ----------- |
      | `letter` | <ApiLink name="uint32_t" /> | a letter    |

      **Returns:** <ApiLink name="bool" /> — false: 'letter' is not break char
    </ApiMember>

    <ApiMember kind="function" name="lv_text_is_a_word" file="misc/lv_text_private.h" line="167" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L167">
      lv_text_is_a_word [#lv_text_is_a_word]

      Test if char is break char or not (a text can broken here or not)

      ```c title=" " lineNumbers=1
      static bool lv_text_is_a_word(uint32_t letter)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                        | Description |
      | -------- | --------------------------- | ----------- |
      | `letter` | <ApiLink name="uint32_t" /> | a letter    |

      **Returns:** <ApiLink name="bool" /> — false: 'letter' is not break char
    </ApiMember>

    <ApiMember kind="function" name="lv_text_is_marker" file="misc/lv_text_private.h" line="222" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L222">
      lv_text_is_marker [#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.

      ```c title=" " lineNumbers=1
      static bool lv_text_is_marker(uint32_t letter)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                        | Description |
      | -------- | --------------------------- | ----------- |
      | `letter` | <ApiLink name="uint32_t" /> | a letter    |

      **Returns:** <ApiLink name="bool" /> — true if so
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="lv_text_cmd_state_t" file="misc/lv_text_private.h" line="37" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L37">
  lv_text_cmd_state_t [#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   |
</ApiMember>

<TypeUsedBy name="lv_text_cmd_state_t" count="1">
  * `lv_text_is_cmd` — param `state`
</TypeUsedBy>

Structs [#structs]

<ApiMember kind="struct" name="lv_text_attributes_t">
  lv_text_attributes_t [#lv_text_attributes_t]

  | Member         | Type                              | Description                                                                       |
  | -------------- | --------------------------------- | --------------------------------------------------------------------------------- |
  | `letter_space` | <ApiLink name="int32_t" />        | Letter space between letters                                                      |
  | `line_space`   | <ApiLink name="int32_t" />        | Space between lines of text                                                       |
  | `max_width`    | <ApiLink name="int32_t" />        | Max width of the text (break the lines to fit this size). Set COORD\_MAX to avoid |
  | `text_flags`   | <ApiLink name="lv_text_flag_t" /> |                                                                                   |
</ApiMember>

<TypeUsedBy name="lv_text_attributes_t" count="4">
  * `lv_text_attributes_init` — param `attributes`
  * `lv_text_get_size_attributes` — param `attributes`
  * `lv_text_get_width` — param `attributes`
  * `lv_text_get_next_line` — param `attributes`
</TypeUsedBy>

Macros [#macros]

<ApiMember kind="macro" name="LV_TXT_ENC_UTF8" file="misc/lv_text_private.h" line="27" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L27">
  LV_TXT_ENC_UTF8 [#lv_txt_enc_utf8]

  ```c title=" " lineNumbers=1
  #define LV_TXT_ENC_UTF8 1
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_TXT_ENC_ASCII" file="misc/lv_text_private.h" line="28" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L28">
  LV_TXT_ENC_ASCII [#lv_txt_enc_ascii]

  ```c title=" " lineNumbers=1
  #define LV_TXT_ENC_ASCII 2
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_TEXT_LEN_MAX" file="misc/lv_text_private.h" line="30" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L30">
  LV_TEXT_LEN_MAX [#lv_text_len_max]

  ```c title=" " lineNumbers=1
  #define LV_TEXT_LEN_MAX UINT32_MAX
  ```
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_text_encoded_size" file="misc/lv_text_private.h" line="259" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L259">
  lv_text_encoded_size [#lv_text_encoded_size]

  ```c title=" " lineNumbers=1
  uint8_t(*const lv_text_encoded_size
  ```

  Give the size of an encoded character
</ApiMember>

<ApiMember kind="variable" name="lv_text_unicode_to_encoded" file="misc/lv_text_private.h" line="266" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L266">
  lv_text_unicode_to_encoded [#lv_text_unicode_to_encoded]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_unicode_to_encoded
  ```

  Convert a Unicode letter to encoded
</ApiMember>

<ApiMember kind="variable" name="lv_text_encoded_conv_wc" file="misc/lv_text_private.h" line="273" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L273">
  lv_text_encoded_conv_wc [#lv_text_encoded_conv_wc]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_encoded_conv_wc
  ```

  Convert a wide character, e.g. 'Á' little endian to be compatible with the encoded format.
</ApiMember>

<ApiMember kind="variable" name="lv_text_encoded_next" file="misc/lv_text_private.h" line="283" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L283">
  lv_text_encoded_next [#lv_text_encoded_next]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_encoded_next
  ```

  Decode the next encoded character from a string.
</ApiMember>

<ApiMember kind="variable" name="lv_text_encoded_prev" file="misc/lv_text_private.h" line="294" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L294">
  lv_text_encoded_prev [#lv_text_encoded_prev]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_encoded_prev
  ```

  Get the previous encoded character form a string.
</ApiMember>

<ApiMember kind="variable" name="lv_text_encoded_get_byte_id" file="misc/lv_text_private.h" line="303" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L303">
  lv_text_encoded_get_byte_id [#lv_text_encoded_get_byte_id]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_encoded_get_byte_id
  ```

  Convert 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
</ApiMember>

<ApiMember kind="variable" name="lv_text_encoded_get_char_id" file="misc/lv_text_private.h" line="312" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L312">
  lv_text_encoded_get_char_id [#lv_text_encoded_get_char_id]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_encoded_get_char_id
  ```

  Convert 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
</ApiMember>

<ApiMember kind="variable" name="lv_text_get_encoded_length" file="misc/lv_text_private.h" line="320" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text_private.h#L320">
  lv_text_get_encoded_length [#lv_text_get_encoded_length]

  ```c title=" " lineNumbers=1
  uint32_t(*const lv_text_get_encoded_length
  ```

  Get the number of characters (and NOT bytes) in a string. E.g. in UTF-8 "ÁBC" is 3 characters (but 4 bytes)
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_text.h&#x22;]" transitiveIncludes="[&#x22;lv_area.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_types.h&#x22;]" />
