# lv_bidi_private.h (/api/private/misc/lv_bidi_private_h)



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

<ApiSummary functions="6" />

Functions [#functions]

<ApiTabs items="[&#x22;Getters (2)&#x22;,&#x22;Other (4)&#x22;]">
  <ApiTab value="Getters (2)">
    <ApiMember kind="function" name="lv_bidi_get_logical_pos" file="private/misc/lv_bidi_private.h" line="64" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L64">
      lv_bidi_get_logical_pos [#lv_bidi_get_logical_pos]

      Get the logical position of a character in a line

      ```c title=" " lineNumbers=1
      uint16_t lv_bidi_get_logical_pos(const char *str_in, char **bidi_txt, uint32_t len, lv_base_dir_t base_dir, uint32_t visual_pos, bool *is_rtl)
      ```

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

      | Name         | Type                             | Description                                                                                                                                                                          |
      | ------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
      | `str_in`     | `const char *`                   | the input string. Can be only one line.                                                                                                                                              |
      | `bidi_txt`   | `char **`                        | internally the text is bidi processed which buffer can be get here. If not required anymore has to freed with <ApiLink name="lv_free" display="lv_free()" /> Can be `NULL` is unused |
      | `len`        | `uint32_t`                       | length of the line in character count                                                                                                                                                |
      | `base_dir`   | <ApiLink name="lv_base_dir_t" /> | base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`                                                                                                                   |
      | `visual_pos` | `uint32_t`                       | the visual character position which logical position should be get                                                                                                                   |
      | `is_rtl`     | `bool *`                         | tell the char at `visual_pos` is RTL or LTR context                                                                                                                                  |

      **Returns:** `uint16_t` — the logical character position
    </ApiMember>

    <ApiMember kind="function" name="lv_bidi_get_visual_pos" file="private/misc/lv_bidi_private.h" line="79" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L79">
      lv_bidi_get_visual_pos [#lv_bidi_get_visual_pos]

      Get the visual position of a character in a line

      ```c title=" " lineNumbers=1
      uint16_t lv_bidi_get_visual_pos(const char *str_in, char **bidi_txt, uint16_t len, lv_base_dir_t base_dir, uint32_t logical_pos, bool *is_rtl)
      ```

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

      | Name          | Type                             | Description                                                                                                                                                                          |
      | ------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
      | `str_in`      | `const char *`                   | the input string. Can be only one line.                                                                                                                                              |
      | `bidi_txt`    | `char **`                        | internally the text is bidi processed which buffer can be get here. If not required anymore has to freed with <ApiLink name="lv_free" display="lv_free()" /> Can be `NULL` is unused |
      | `len`         | `uint16_t`                       | length of the line in character count                                                                                                                                                |
      | `base_dir`    | <ApiLink name="lv_base_dir_t" /> | base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`                                                                                                                   |
      | `logical_pos` | `uint32_t`                       | the logical character position which visual position should be get                                                                                                                   |
      | `is_rtl`      | `bool *`                         | tell the char at `logical_pos` is RTL or LTR context                                                                                                                                 |

      **Returns:** `uint16_t` — the visual character position
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (4)">
    <ApiMember kind="function" name="lv_bidi_process" file="private/misc/lv_bidi_private.h" line="39" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L39">
      lv_bidi_process [#lv_bidi_process]

      Convert a text to get the characters in the correct visual order according to Unicode Bidirectional Algorithm

      ```c title=" " lineNumbers=1
      void lv_bidi_process(const char *str_in, char *str_out, lv_base_dir_t base_dir)
      ```

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

      | Name       | Type                             | Description                                               |
      | ---------- | -------------------------------- | --------------------------------------------------------- |
      | `str_in`   | `const char *`                   | the text to process                                       |
      | `str_out`  | `char *`                         | store the result here. Has the be `strlen(str_in)` length |
      | `base_dir` | <ApiLink name="lv_base_dir_t" /> | `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`                    |
    </ApiMember>

    <ApiMember kind="function" name="lv_bidi_detect_base_dir" file="private/misc/lv_bidi_private.h" line="50" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L50">
      lv_bidi_detect_base_dir [#lv_bidi_detect_base_dir]

      Auto-detect the base direction of a text by scanning all strong characters. RTL takes priority: if any RTL strong character is found, `LV_BASE_DIR_RTL` is returned immediately. Otherwise, `LV_BASE_DIR_LTR` is returned if any LTR strong character is found. If no strong character is present, falls back to `LV_BIDI_BASE_DIR_DEF`. When `LV_BIDI_BASE_DIR_DEF` is `LV_BASE_DIR_AUTO`, this function returns `LV_BASE_DIR_LTR`.

      ```c title=" " lineNumbers=1
      lv_base_dir_t lv_bidi_detect_base_dir(const char *txt)
      ```

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

      | Name  | Type           | Description         |
      | ----- | -------------- | ------------------- |
      | `txt` | `const char *` | the text to process |

      **Returns:** <ApiLink name="lv_base_dir_t" /> — `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
    </ApiMember>

    <ApiMember kind="function" name="lv_bidi_process_paragraph" file="private/misc/lv_bidi_private.h" line="92" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L92">
      lv_bidi_process_paragraph [#lv_bidi_process_paragraph]

      Bidi process a paragraph of text

      ```c title=" " lineNumbers=1
      void lv_bidi_process_paragraph(const char *str_in, char *str_out, uint32_t len, lv_base_dir_t base_dir, uint16_t *pos_conv_out, uint16_t pos_conv_len)
      ```

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

      | Name           | Type                             | Description                                                                                         |
      | -------------- | -------------------------------- | --------------------------------------------------------------------------------------------------- |
      | `str_in`       | `const char *`                   | the string to process                                                                               |
      | `str_out`      | `char *`                         | store the result here                                                                               |
      | `len`          | `uint32_t`                       | length of the text                                                                                  |
      | `base_dir`     | <ApiLink name="lv_base_dir_t" /> | base dir of the text                                                                                |
      | `pos_conv_out` | `uint16_t *`                     | an `uint16_t` array to store the related logical position of the character. Can be `NULL` is unused |
      | `pos_conv_len` | `uint16_t`                       | length of `pos_conv_out` in element count                                                           |
    </ApiMember>

    <ApiMember kind="function" name="lv_bidi_calculate_align_internal" file="private/misc/lv_bidi_private.h" line="102" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/src/misc/lv_bidi_private.h#L102">
      lv_bidi_calculate_align_internal [#lv_bidi_calculate_align_internal]

      Internal implementation of <ApiLink name="lv_bidi_calculate_align" />

      ```c title=" " lineNumbers=1
      static void lv_bidi_calculate_align_internal(lv_text_align_t *align, lv_base_dir_t *base_dir, const char *txt)
      ```

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

      | Name       | Type                                                           |
      | ---------- | -------------------------------------------------------------- |
      | `align`    | <ApiLink name="lv_text_align_t" display="lv_text_align_t *" /> |
      | `base_dir` | <ApiLink name="lv_base_dir_t" display="lv_base_dir_t *" />     |
      | `txt`      | `const char *`                                                 |
    </ApiMember>
  </ApiTab>
</ApiTabs>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lvgl_public.h&#x22;]" includedBy="[&#x22;lvgl_private.h&#x22;]" />
