Tiny TTF create from file


I’m testing tinyTTF to change the font size at runtime.

Embedding and using the font file (use lv_tiny_ttf_create_data) was successful.
To reduce FW size during OTA, I tried including a font file in the filesystem(use SPIFFS) and streaming from the file (use lv_tiny_ttf_create_file), but it can’t create fonts.

The code was written using lv_fs_if for the LVGL filesystem interface. (use lv_fs_pc.c because the STDIO API is supported in ESP32)

What MCU/Processor/Board and compiler are you using?


What do you want to achieve?

Create dynamic font data at runtime(from filesystem) using Tiny TTF.

What have you tried so far?

I used lv_fs_open to directly open the font file in the file system and read the data. This was successful.

But when I try using lv_tiny_ttf_create_file, it blocked within the function.

Code to reproduce

Below is the file open test code.
This has been tried with both LVGL v8.4 and v9.1.

#if 1
  lv_fs_file_t lv_file;
  lv_fs_res_t ret = lv_fs_open(&lv_file, "A:/spiffs/subset_custom.ttf", LV_FS_MODE_RD);
  ESP_LOGI(TAG, "%d", ret);

  uint8_t buf[3];
  uint32_t br;
  ret = lv_fs_read(&lv_file, buf, 3, &br);
  ESP_LOGI(TAG, "%d, %d [%X %X %X]", ret, br, buf[0], buf[1], buf[2]);

  lv_font_t *vectorFont = NULL;
  lv_font_t *vectorFont = lv_tiny_ttf_create_file ("A:/spiffs/subset_custom.ttf", 20);

Screenshot and/or video



lv_tiny_ttf_create_file is success. but if style(lv_style_t) applied with the created font(lv_font_t) is added to the label, it blocked.

  lv_obj_t *vect_label = lv_label_create (lv_scr_act ());
  static lv_style_t vect_style;

  lv_font_t *vectorFont = lv_tiny_ttf_create_file ("A:/spiffs/subset_custom.ttf", 20);
  lv_style_set_text_font(&vect_style, vectorFont);
  lv_style_set_text_align(&vect_style, LV_TEXT_ALIGN_CENTER);
  lv_obj_add_style(vect_label, &vect_style, 0); // blocked point

I also have block problems.
Is it resolved?

It’s not completely resolved, but I found the cause.

It seems to be blocked because rendering the ttf file in the file is very slow.

For ESP32, the default task watchdog is 5 seconds, so try increasing this value.

However, rendering will still be very slow. This is confirmed to be an issue related to TinyTTF’s glyph descriptor callback.

Please refer to this link

I set it up as follows.
After booting, task wdt occurs as shown in the image below.

Is there a solution?