# lv_text.h (/api/misc/lv_text_h)



<RelatedHeaders name="lv_text_private.h" isPrivate="false" />

<ApiSummary functions="3" enums="3" />

Functions [#functions]

<ApiMember kind="function" name="lv_font_get_top_trim" file="misc/lv_text.h" line="96" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L96">
  lv_font_get_top_trim [#lv_font_get_top_trim]

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

  ```c title=" " lineNumbers=1
  static int32_t lv_font_get_top_trim(const lv_font_t *font, lv_text_leading_trim_t trim)
  ```

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

  | Name   | Type                                                     | Description       |
  | ------ | -------------------------------------------------------- | ----------------- |
  | `font` | <ApiLink name="lv_font_t" display="const lv_font_t *" /> | pointer to a font |
  | `trim` | <ApiLink name="lv_text_leading_trim_t" />                | leading-trim mode |

  **Returns:** <ApiLink name="int32_t" /> — pixels to trim from the top (0 if no trimming)
</ApiMember>

<ApiMember kind="function" name="lv_font_get_bottom_trim" file="misc/lv_text.h" line="118" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L118">
  lv_font_get_bottom_trim [#lv_font_get_bottom_trim]

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

  ```c title=" " lineNumbers=1
  static int32_t lv_font_get_bottom_trim(const lv_font_t *font, lv_text_leading_trim_t trim)
  ```

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

  | Name   | Type                                                     | Description       |
  | ------ | -------------------------------------------------------- | ----------------- |
  | `font` | <ApiLink name="lv_font_t" display="const lv_font_t *" /> | pointer to a font |
  | `trim` | <ApiLink name="lv_text_leading_trim_t" />                | leading-trim mode |

  **Returns:** <ApiLink name="int32_t" /> — pixels to trim from the bottom (0 if no trimming)
</ApiMember>

<ApiMember kind="function" name="lv_text_get_size" file="misc/lv_text.h" line="140" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L140">
  lv_text_get_size [#lv_text_get_size]

  Get size of a text

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

  <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                                                       |
  | `letter_space` | <ApiLink name="int32_t" />                               | letter space of the text                                                          |
  | `line_space`   | <ApiLink name="int32_t" />                               | line space of the text                                                            |
  | `max_width`    | <ApiLink name="int32_t" />                               | max width of the text (break the lines to fit this size). Set COORD\_MAX to avoid |
  | `flag`         | <ApiLink name="lv_text_flag_t" />                        | settings for the text from <ApiLink name="lv_text_flag_t" />                      |
</ApiMember>

Enums [#enums]

<ApiMember kind="enum" name="lv_text_flag_t" file="misc/lv_text.h" line="33" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L33">
  lv_text_flag_t [#lv_text_flag_t]

  Options for text rendering.

  | Name                     | Value  | Description                                                                                                                                                                                                                                                                                          |
  | ------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `LV_TEXT_FLAG_NONE`      | `0x00` |                                                                                                                                                                                                                                                                                                      |
  | `LV_TEXT_FLAG_EXPAND`    | `0x01` | Ignore max-width to avoid automatic word wrapping                                                                                                                                                                                                                                                    |
  | `LV_TEXT_FLAG_FIT`       | `0x02` | Max-width is already equal to the longest line. (Used to skip some calculation)                                                                                                                                                                                                                      |
  | `LV_TEXT_FLAG_BREAK_ALL` | `0x04` | 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. |
  | `LV_TEXT_FLAG_RECOLOR`   | `0x08` | Enable parsing of recolor command                                                                                                                                                                                                                                                                    |
</ApiMember>

<TypeUsedBy name="lv_text_flag_t" count="1">
  * `lv_text_get_size` — param `flag`
</TypeUsedBy>

<ApiMember kind="enum" name="lv_text_align_t" file="misc/lv_text.h" line="54" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L54">
  lv_text_align_t [#lv_text_align_t]

  Label align policy

  | Name                   | Description          |
  | ---------------------- | -------------------- |
  | `LV_TEXT_ALIGN_AUTO`   | Align text auto      |
  | `LV_TEXT_ALIGN_LEFT`   | Align text to left   |
  | `LV_TEXT_ALIGN_CENTER` | Align text to center |
  | `LV_TEXT_ALIGN_RIGHT`  | Align text to right  |
</ApiMember>

<TypeUsedBy name="lv_text_align_t" count="5">
  * `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`
</TypeUsedBy>

<ApiMember kind="enum" name="lv_text_leading_trim_t" file="misc/lv_text.h" line="64" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_text.h#L64">
  lv_text_leading_trim_t [#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](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-box-edge)

  | Name                                    | Value | Description                                                                                                                                                          |
  | --------------------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `LV_TEXT_LEADING_TRIM_NONE`             | `0`   | No trimming (default behavior)                                                                                                                                       |
  | `LV_TEXT_LEADING_TRIM_CAPITAL_BASELINE` |       | Trim to the top of the capital letters (cap height) and the bottom to the (alphabetic) baseline                                                                      |
  | `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) |
  | `LV_TEXT_LEADING_TRIM_CAPITAL`          |       | Trim only the top to the height of the lower case letters (x-height)                                                                                                 |
  | `LV_TEXT_LEADING_TRIM_LOWER`            |       |                                                                                                                                                                      |
</ApiMember>

<TypeUsedBy name="lv_text_leading_trim_t" count="4">
  * `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`
</TypeUsedBy>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_types.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_sprintf.h&#x22;]" includedBy="[&#x22;lv_draw.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_text_ap.h&#x22;, &#x22;lv_text_private.h&#x22;, &#x22;lv_label.h&#x22;]" transitiveIncludes="[&#x22;lv_assert.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_draw_buf.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_string.h&#x22;, &#x22;lv_symbol_def.h&#x22;]" />
