From fd7335485be398a49b6202b4344d53b1927a4ff8 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Thu, 4 Feb 2021 18:30:19 +0100 Subject: [PATCH] More flexible font defines --- include/lv_conf_v7.h | 14 ++++++++++---- src/hasp/hasp_attribute.cpp | 28 ++++++++-------------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/include/lv_conf_v7.h b/include/lv_conf_v7.h index 0c1d1935..809da864 100644 --- a/include/lv_conf_v7.h +++ b/include/lv_conf_v7.h @@ -377,10 +377,16 @@ typedef void* lv_font_user_data_t; /*Always set a default font from the built-in fonts*/ #if LV_HIGH_RESOURCE_MCU>0 // #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_montserrat_16); -#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(robotocondensed_regular_12_nokern) \ - LV_FONT_DECLARE(robotocondensed_regular_22_nokern) \ - LV_FONT_DECLARE(robotocondensed_regular_16_nokern) \ - LV_FONT_DECLARE(robotocondensed_regular_28_nokern) \ + +#define LV_FONT_CUSTOM_12 LV_FONT_DECLARE(robotocondensed_regular_12_nokern) +#define LV_FONT_CUSTOM_16 LV_FONT_DECLARE(robotocondensed_regular_16_nokern) +#define LV_FONT_CUSTOM_22 LV_FONT_DECLARE(robotocondensed_regular_22_nokern) +#define LV_FONT_CUSTOM_28 LV_FONT_DECLARE(robotocondensed_regular_28_nokern) + +#define LV_FONT_CUSTOM_DECLARE LV_FONT_CUSTOM_12 \ + LV_FONT_CUSTOM_16 \ + LV_FONT_CUSTOM_22 \ + LV_FONT_CUSTOM_28 \ #define LV_FONT_DEFAULT &robotocondensed_regular_16_nokern //&lv_font_montserrat_16 #else diff --git a/src/hasp/hasp_attribute.cpp b/src/hasp/hasp_attribute.cpp index 8328f193..ef2395a1 100644 --- a/src/hasp/hasp_attribute.cpp +++ b/src/hasp/hasp_attribute.cpp @@ -636,36 +636,24 @@ static lv_font_t * haspPayloadToFont(const char * payload) #if ESP32 - #if LV_FONT_MONTSERRAT_12 > 0 + #ifdef LV_FONT_CUSTOM_12 case 12: - return &lv_font_montserrat_12; - #else - case 12: - return &robotocondensed_regular_12_nokern; + return LV_THEME_DEFAULT_FONT_SMALL; #endif - #if LV_FONT_MONTSERRAT_16 > 0 + #ifdef LV_FONT_CUSTOM_16 case 16: - return &lv_font_montserrat_16; - #else - case 16: - return &robotocondensed_regular_16_nokern; + return LV_THEME_DEFAULT_FONT_NORMAL; #endif - #if LV_FONT_MONTSERRAT_22 > 0 + #ifdef LV_FONT_CUSTOM_22 case 22: - return &lv_font_montserrat_22; - #else - case 22: - return &robotocondensed_regular_22_nokern; + return LV_THEME_DEFAULT_FONT_SUBTITLE; #endif - #if LV_FONT_MONTSERRAT_28 > 0 + #ifdef LV_FONT_CUSTOM_28 case 28: - return &lv_font_montserrat_28_compressed; - #else - case 28: - return &robotocondensed_regular_28_nokern; + return LV_THEME_DEFAULT_FONT_TITLE; #endif #endif