diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 5d174fd..40afc2d 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -253,6 +253,11 @@ swap_coord(T& a, T& b) { T t = a; a = b; b = t; } // This is a structure to conveniently hold infomation on the default fonts // Stores pointer to font character image address table, width table and height +// Create a null set in case some fonts not used (to prevent crash) +const uint8_t widtbl_null[1] = {0}; +PROGMEM const uint8_t chr_null[1] = {0}; +PROGMEM const uint8_t* const chrtbl_null[1] = {chr_null}; + typedef struct { const uint8_t *chartbl; const uint8_t *widthtbl; @@ -262,45 +267,45 @@ typedef struct { // Now fill the structure const PROGMEM fontinfo fontdata [] = { - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, // GLCD font (Font 1) does not have all parameters - { 0, 0, 8, 7 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 8, 7 }, #ifdef LOAD_FONT2 { (const uint8_t *)chrtbl_f16, widtbl_f16, chr_hgt_f16, baseline_f16}, #else - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #endif // Font 3 current unused - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #ifdef LOAD_FONT4 { (const uint8_t *)chrtbl_f32, widtbl_f32, chr_hgt_f32, baseline_f32}, #else - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #endif // Font 5 current unused - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #ifdef LOAD_FONT6 { (const uint8_t *)chrtbl_f64, widtbl_f64, chr_hgt_f64, baseline_f64}, #else - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #endif #ifdef LOAD_FONT7 { (const uint8_t *)chrtbl_f7s, widtbl_f7s, chr_hgt_f7s, baseline_f7s}, #else - { 0, 0, 0, 0 }, + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 }, #endif #ifdef LOAD_FONT8 { (const uint8_t *)chrtbl_f72, widtbl_f72, chr_hgt_f72, baseline_f72} #else - { 0, 0, 0, 0 } + { (const uint8_t *)chrtbl_null, widtbl_null, 0, 0 } #endif };