Fix for zifont crash

This commit is contained in:
fvanroie 2021-03-16 15:27:19 +01:00
parent dfb3c13238
commit 984f8d918d
2 changed files with 9 additions and 5 deletions

View File

@ -68,7 +68,7 @@ lv_zifont_char_t lastCharInfo; // Holds the last Glyph DSC
#if ESP32
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
#define CHAR_CACHE_SIZE 95
#define CHAR_CACHE_SIZE 224
#else
#define CHAR_CACHE_SIZE 95
// static lv_zifont_char_t charCache[256 - 32]; // glyphID DSC cache
@ -104,7 +104,7 @@ static inline bool openFont(File& file, const char* filename)
LOG_ERROR(TAG_FONT, F("Opening font: %s"), filename);
return false;
}
LOG_TRACE(TAG_FONT, F("Opening font: %s"), filename);
// LOG_TRACE(TAG_FONT, F("Opening font: %s"), filename);
return file;
}
@ -128,6 +128,7 @@ static inline bool initCharacterFrame(size_t size)
int lv_zifont_font_init(lv_font_t** font, const char* font_path, uint16_t size)
{
charInBuffer = 0; // invalidate any previous cache
LOG_TRACE(TAG_FONT, F("File %s - Line %d - lv_zifont_font_init"), __FILE__, __LINE__);
if(!*font) {
LOG_TRACE(TAG_FONT, F("File %s - Line %d - init font"), __FILE__, __LINE__);

View File

@ -93,8 +93,8 @@ lv_obj_t* kb;
// lv_font_t * defaultFont;
lv_obj_t* pages[HASP_NUM_PAGES];
static lv_font_t* haspFonts[4] = {nullptr, LV_THEME_DEFAULT_FONT_NORMAL, LV_THEME_DEFAULT_FONT_SUBTITLE,
LV_THEME_DEFAULT_FONT_TITLE};
static lv_font_t* haspFonts[4] = {LV_THEME_DEFAULT_FONT_SMALL, LV_THEME_DEFAULT_FONT_NORMAL,
LV_THEME_DEFAULT_FONT_SUBTITLE, LV_THEME_DEFAULT_FONT_TITLE};
uint8_t current_page = 1;
/**
@ -365,13 +365,16 @@ void haspSetup(void)
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
lv_font_t* hasp_font = nullptr; // required or font init will crash
lv_zifont_init();
if(lv_zifont_font_init(&haspFonts[1], haspZiFontPath, 32) != 0) {
// WARNING: hasp_font needs to be null !
if(lv_zifont_font_init(&hasp_font, haspZiFontPath, 32) != 0) {
LOG_ERROR(TAG_HASP, F("Failed to set font to %s"), haspZiFontPath);
haspFonts[1] = LV_FONT_DEFAULT;
} else {
// defaultFont = haspFonts[0];
haspFonts[1] = hasp_font; // save it
}
#endif
#endif