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



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

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

Functions [#functions]

<ApiMember kind="function" name="lv_font_get_bitmap_fmt_txt" file="public/font/lv_font_fmt_txt.h" line="227" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L227">
  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. **May** be `NULL`. 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="public/font/lv_font_fmt_txt.h" line="238" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L238">
  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`      | `uint32_t`                                                             | a UNICODE letter code                               |
  | `unicode_letter_next` | `uint32_t`                                                             | the unicode letter succeeding the letter under test |

  **Returns:** `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="public/font/lv_font_fmt_txt.h" line="49" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L49">
  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="public/font/lv_font_fmt_txt.h" line="146" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L146">
  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` | `uint32_t` | Start index of the bitmap. A font can be max 1 MB.                              |
  | `adv_w`        | `uint32_t` | Draw the next glyph after this width. 8.4 format (real\_value \* 16 is stored). |
  | `box_w`        | `uint8_t`  | Width of the glyph's bounding box                                               |
  | `box_h`        | `uint8_t`  | Height of the glyph's bounding box                                              |
  | `ofs_x`        | `int8_t`   | x offset of the bounding box                                                    |
  | `ofs_y`        | `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`       | `uint32_t`                                     | First Unicode character for this range                                                                                                  |
  | `range_length`      | `uint16_t`                                     | Number of Unicode characters related to this range. Last Unicode character = range\_start + range\_length - 1                           |
  | `glyph_id_start`    | `uint16_t`                                     | First glyph ID (array index of `glyph_dsc`) for this range                                                                              |
  | `unicode_list`      | `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`       | `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`         | `const int8_t *` |                                                         |
  | `pair_cnt`       | `uint32_t`       |                                                         |
  | `glyph_ids_size` | `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`   | `const int8_t *`  | left\_class\_cnt \* right\_class\_cnt value                    |
  | `left_class_mapping`  | `const uint8_t *` | Map the glyph\_ids to classes: index -> glyph\_id -> class\_id |
  | `right_class_mapping` | `const uint8_t *` | Map the glyph\_ids to classes: index -> glyph\_id -> class\_id |
  | `left_class_cnt`      | `uint8_t`         |                                                                |
  | `right_class_cnt`     | `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`              | `const uint8_t *`                                                                            | The bitmaps of all glyphs or a lv\_font\_fmt\_txt\_glyph\_loader\_t \* depending on the state of `are_glyphs_dynamic_loaded` a uint8\_t to preserve backwards compatibility                                              |
  | `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 <ApiLink name="lv_font_fmt_txt_kern_classes_t" /> \* depending on `kern_classes`                                                       |
  | `kern_scale`                | `uint16_t`                                                                                   | Scale kern values in 12.4 format                                                                                                                                                                                         |
  | `cmap_num`                  | `uint16_t`                                                                                   | Number of cmap tables                                                                                                                                                                                                    |
  | `bpp`                       | `uint8_t`                                                                                    | Bit per pixel: 1, 2, 3, 4, 8                                                                                                                                                                                             |
  | `kern_classes`              | `uint8_t`                                                                                    | Type of `kern_dsc`                                                                                                                                                                                                       |
  | `bitmap_format`             | `uint8_t`                                                                                    | storage format of the bitmap from `lv_font_fmt_txt_bitmap_format_t`                                                                                                                                                      |
  | `stride`                    | `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 |
  | `are_glyphs_dynamic_loaded` | `bool`                                                                                       | `false`: the glyph bitmaps are stored in `glyph_bitmap`<br /><br />`true`: the glyph bitmaps are loaded on demand and `glyph_bitmap` holds a `lv_font_fmt_txt_glyph_loader_t *` instead                                  |
</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`   | `uint32_t`                                               |                          |
</ApiMember>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_font_fmt_txt_glyph_loader_t" file="public/font/lv_font_fmt_txt.h" line="27" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L27">
  lv_font_fmt_txt_glyph_loader_t [#lv_font_fmt_txt_glyph_loader_t]

  ```c title=" " lineNumbers=1
  typedef struct _lv_font_fmt_txt_glyph_loader_t lv_font_fmt_txt_glyph_loader_t
  ```
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_builtin_font_class" file="public/font/lv_font_fmt_txt.h" line="214" url="https://github.com/lvgl/lvgl/tree/e1a0ad863f29742359bc680d6a7d973448ec2285/include/lvgl/font/lv_font_fmt_txt.h#L214">
  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;lvgl.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_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;]" />
