# lv_font_fmt_txt.h (/api/font/fmt_txt/lv_font_fmt_txt_h)



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

<ApiSummary functions="2" enums="2" structs="6" variables="1" />

Functions [#functions]

<ApiMember kind="function" name="lv_font_get_bitmap_fmt_txt" file="font/fmt_txt/lv_font_fmt_txt.h" line="213" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/font/fmt_txt/lv_font_fmt_txt.h#L213">
  lv_font_get_bitmap_fmt_txt [#lv_font_get_bitmap_fmt_txt]

  Used as `get_glyph_bitmap` callback in lvgl's native font format if the font is uncompressed.

  ```c title=" " lineNumbers=1
  const void * lv_font_get_bitmap_fmt_txt(lv_font_glyph_dsc_t *g_dsc, lv_draw_buf_t *draw_buf)
  ```

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

  | Name       | Type                                                                   | Description                                                                                 |
  | ---------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
  | `g_dsc`    | <ApiLink name="lv_font_glyph_dsc_t" display="lv_font_glyph_dsc_t *" /> | the glyph descriptor including which font to use, which supply the glyph\_index and format. |
  | `draw_buf` | <ApiLink name="lv_draw_buf_t" display="lv_draw_buf_t *" />             | a draw buffer that can be used to store the bitmap of the glyph, it's OK not to use it.     |

  **Returns:** `const void *` — pointer to an A8 bitmap (not necessarily bitmap\_out) or NULL if `unicode_letter` not found
</ApiMember>

<ApiMember kind="function" name="lv_font_get_glyph_dsc_fmt_txt" file="font/fmt_txt/lv_font_fmt_txt.h" line="224" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/font/fmt_txt/lv_font_fmt_txt.h#L224">
  lv_font_get_glyph_dsc_fmt_txt [#lv_font_get_glyph_dsc_fmt_txt]

  Used as `get_glyph_dsc` callback in lvgl's native font format if the font is uncompressed.

  ```c title=" " lineNumbers=1
  bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t *font, lv_font_glyph_dsc_t *dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
  ```

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

  | Name                  | Type                                                                   | Description                                         |
  | --------------------- | ---------------------------------------------------------------------- | --------------------------------------------------- |
  | `font`                | <ApiLink name="lv_font_t" display="const lv_font_t *" />               | pointer to font                                     |
  | `dsc_out`             | <ApiLink name="lv_font_glyph_dsc_t" display="lv_font_glyph_dsc_t *" /> | store the result descriptor here                    |
  | `unicode_letter`      | <ApiLink name="uint32_t" />                                            | a UNICODE letter code                               |
  | `unicode_letter_next` | <ApiLink name="uint32_t" />                                            | the unicode letter succeeding the letter under test |

  **Returns:** <ApiLink name="bool" /> — true: descriptor is successfully loaded into `dsc_out`. false: the letter was not found, no data is loaded to `dsc_out`
</ApiMember>

Enums [#enums]

<ApiMember kind="enum" name="lv_font_fmt_txt_cmap_type_t" file="font/fmt_txt/lv_font_fmt_txt.h" line="47" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/font/fmt_txt/lv_font_fmt_txt.h#L47">
  lv_font_fmt_txt_cmap_type_t [#lv_font_fmt_txt_cmap_type_t]

  Format of font character map.

  | Name                                |
  | ----------------------------------- |
  | `LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL` |
  | `LV_FONT_FMT_TXT_CMAP_SPARSE_FULL`  |
  | `LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY` |
  | `LV_FONT_FMT_TXT_CMAP_SPARSE_TINY`  |
</ApiMember>

<ApiMember kind="enum" name="lv_font_fmt_txt_bitmap_format_t" file="font/fmt_txt/lv_font_fmt_txt.h" line="144" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/font/fmt_txt/lv_font_fmt_txt.h#L144">
  lv_font_fmt_txt_bitmap_format_t [#lv_font_fmt_txt_bitmap_format_t]

  Bitmap formats

  | Name                                      | Value |
  | ----------------------------------------- | ----- |
  | `LV_FONT_FMT_TXT_PLAIN`                   | `0`   |
  | `LV_FONT_FMT_TXT_COMPRESSED`              | `1`   |
  | `LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER` | `2`   |
</ApiMember>

Structs [#structs]

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

  This describes a glyph.

  | Member         | Type                        | Description                                                                     |
  | -------------- | --------------------------- | ------------------------------------------------------------------------------- |
  | `bitmap_index` | <ApiLink name="uint32_t" /> | Start index of the bitmap. A font can be max 1 MB.                              |
  | `adv_w`        | <ApiLink name="uint32_t" /> | Draw the next glyph after this width. 8.4 format (real\_value \* 16 is stored). |
  | `box_w`        | <ApiLink name="uint8_t" />  | Width of the glyph's bounding box                                               |
  | `box_h`        | <ApiLink name="uint8_t" />  | Height of the glyph's bounding box                                              |
  | `ofs_x`        | <ApiLink name="int8_t" />   | x offset of the bounding box                                                    |
  | `ofs_y`        | <ApiLink name="int8_t" />   | y offset of the bounding box. Measured from the top of the line                 |
</ApiMember>

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

  Map codepoints to a `glyph_dsc`s Several formats are supported to optimize memory usage See [https://github.com/lvgl/lv\_font\_conv/blob/master/doc/font\_spec.md](https://github.com/lvgl/lv_font_conv/blob/master/doc/font_spec.md)

  | Member              | Type                                                   | Description                                                                                                                             |
  | ------------------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
  | `range_start`       | <ApiLink name="uint32_t" />                            | First Unicode character for this range                                                                                                  |
  | `range_length`      | <ApiLink name="uint16_t" />                            | Number of Unicode characters related to this range. Last Unicode character = range\_start + range\_length - 1                           |
  | `glyph_id_start`    | <ApiLink name="uint16_t" />                            | First glyph ID (array index of `glyph_dsc`) for this range                                                                              |
  | `unicode_list`      | <ApiLink name="uint16_t" display="const uint16_t *" /> |                                                                                                                                         |
  | `glyph_id_ofs_list` | `const void *`                                         | if(type == LV\_FONT\_FMT\_TXT\_CMAP\_FORMAT0\_...) it's `uint8_t *` if(type == LV\_FONT\_FMT\_TXT\_CMAP\_SPARSE\_...) it's `uint16_t *` |
  | `list_length`       | <ApiLink name="uint16_t" />                            | Length of `unicode_list` and/or `glyph_id_ofs_list`                                                                                     |
  | `type`              | <ApiLink name="lv_font_fmt_txt_cmap_type_t" />         | Type of this character map                                                                                                              |
</ApiMember>

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

  A simple mapping of kern values from pairs

  | Member           | Type                                               | Description                                             |
  | ---------------- | -------------------------------------------------- | ------------------------------------------------------- |
  | `glyph_ids`      | `const void *`                                     |                                                         |
  | `values`         | <ApiLink name="int8_t" display="const int8_t *" /> |                                                         |
  | `pair_cnt`       | <ApiLink name="uint32_t" />                        |                                                         |
  | `glyph_ids_size` | <ApiLink name="uint32_t" />                        | 0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t` |
</ApiMember>

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

  More complex but more optimal class based kern value storage

  | Member                | Type                                                 | Description                                                    |
  | --------------------- | ---------------------------------------------------- | -------------------------------------------------------------- |
  | `class_pair_values`   | <ApiLink name="int8_t" display="const int8_t *" />   | left\_class\_cnt \* right\_class\_cnt value                    |
  | `left_class_mapping`  | <ApiLink name="uint8_t" display="const uint8_t *" /> | Map the glyph\_ids to classes: index -> glyph\_id -> class\_id |
  | `right_class_mapping` | <ApiLink name="uint8_t" display="const uint8_t *" /> | Map the glyph\_ids to classes: index -> glyph\_id -> class\_id |
  | `left_class_cnt`      | <ApiLink name="uint8_t" />                           |                                                                |
  | `right_class_cnt`     | <ApiLink name="uint8_t" />                           |                                                                |
</ApiMember>

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

  Describe store for additional data for fonts

  | Member          | Type                                                                                         | Description                                                                                                                                                                                                              |
  | --------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
  | `glyph_bitmap`  | <ApiLink name="uint8_t" display="const uint8_t *" />                                         | The bitmaps of all glyphs                                                                                                                                                                                                |
  | `glyph_dsc`     | <ApiLink name="lv_font_fmt_txt_glyph_dsc_t" display="const lv_font_fmt_txt_glyph_dsc_t *" /> | Describe the glyphs                                                                                                                                                                                                      |
  | `cmaps`         | <ApiLink name="lv_font_fmt_txt_cmap_t" display="const lv_font_fmt_txt_cmap_t *" />           | Map the glyphs to Unicode characters. Array of `lv_font_cmap_fmt_txt_t` variables                                                                                                                                        |
  | `kern_dsc`      | `const void *`                                                                               | Store kerning values. Can be <ApiLink name="lv_font_fmt_txt_kern_pair_t" />` * or`lv\_font\_kern\_classes\_fmt\_txt\_t \*` depending on`kern\_classes\`                                                                  |
  | `kern_scale`    | <ApiLink name="uint16_t" />                                                                  | Scale kern values in 12.4 format                                                                                                                                                                                         |
  | `cmap_num`      | <ApiLink name="uint16_t" />                                                                  | Number of cmap tables                                                                                                                                                                                                    |
  | `bpp`           | <ApiLink name="uint16_t" />                                                                  | Bit per pixel: 1, 2, 3, 4, 8                                                                                                                                                                                             |
  | `kern_classes`  | <ApiLink name="uint16_t" />                                                                  | Type of `kern_dsc`                                                                                                                                                                                                       |
  | `bitmap_format` | <ApiLink name="uint16_t" />                                                                  | storage format of the bitmap from `lv_font_fmt_txt_bitmap_format_t`                                                                                                                                                      |
  | `stride`        | <ApiLink name="uint8_t" />                                                                   | Bytes to which each line is padded. 0: means no align and padding 1: e.g. with bpp=4 lines are aligned to 1 byte, so there can be a 4 bits of padding 4, 8, 16, 32, 64: each line is padded to the given byte boundaries |
</ApiMember>

<TypeUsedBy name="lv_font_fmt_txt_dsc_t" count="1">
  * `lv_draw_eve_label_upload_glyph` — param `font_dsc`
</TypeUsedBy>

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

  | Member   | Type                                                     | Description              |
  | -------- | -------------------------------------------------------- | ------------------------ |
  | `font_p` | <ApiLink name="lv_font_t" display="const lv_font_t *" /> | Pointer to built-in font |
  | `size`   | <ApiLink name="uint32_t" />                              |                          |
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_builtin_font_class" file="font/fmt_txt/lv_font_fmt_txt.h" line="201" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/font/fmt_txt/lv_font_fmt_txt.h#L201">
  lv_builtin_font_class [#lv_builtin_font_class]

  ```c title=" " lineNumbers=1
  const lv_font_class_t lv_builtin_font_class
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_font.h&#x22;, &#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_draw_eve_private.h&#x22;, &#x22;lv_font_fmt_txt_private.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_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;]" />
