diff --git a/lv_conf_template.h b/lv_conf_template.h index 96ca4b499..2f146e31f 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -224,40 +224,26 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i * FONT USAGE *===================*/ -/* More info about fonts: https://docs.littlevgl.com/#Fonts - * To enable a built-in font use 1,2,4 or 8 values - * which will determine the bit-per-pixel. Higher value means smoother fonts */ -#define LV_USE_FONT_DEJAVU_10 4 -#define LV_USE_FONT_DEJAVU_10_LATIN_SUP 4 -#define LV_USE_FONT_DEJAVU_10_CYRILLIC 4 -#define LV_USE_FONT_SYMBOL_10 4 - -#define LV_USE_FONT_DEJAVU_20 4 -#define LV_USE_FONT_DEJAVU_20_LATIN_SUP 4 -#define LV_USE_FONT_DEJAVU_20_CYRILLIC 4 -#define LV_USE_FONT_SYMBOL_20 4 - -#define LV_USE_FONT_DEJAVU_30 4 -#define LV_USE_FONT_DEJAVU_30_LATIN_SUP 4 -#define LV_USE_FONT_DEJAVU_30_CYRILLIC 4 -#define LV_USE_FONT_SYMBOL_30 4 - -#define LV_USE_FONT_DEJAVU_40 4 -#define LV_USE_FONT_DEJAVU_40_LATIN_SUP 4 -#define LV_USE_FONT_DEJAVU_40_CYRILLIC 4 -#define LV_USE_FONT_SYMBOL_40 4 - -#define LV_USE_FONT_MONOSPACE_8 1 +/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. + * The symbols are available via `LV_SYMBOL_...` defines + * More info about fonts: https://docs.littlevgl.com/#Fonts + * To create a new font go to: https://littlevgl.com/ttf-font-to-c-array + */ +#define LV_FONT_ROBOTO_12 0 +#define LV_FONT_ROBOTO_16 1 +#define LV_FONT_ROBOTO_22 0 +#define LV_FONT_ROBOTO_28 0 /* Optionally declare your custom fonts here. * You can use these fonts as default font too * and they will be available globally. E.g. * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) \ + * LV_FONT_DECLARE(my_font_2) */ #define LV_FONT_CUSTOM_DECLARE -#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/ +/*Always set a default font from the built-in fonts*/ +#define LV_FONT_DEFAULT &lv_font_roboto_16 /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ typedef void * lv_font_user_data_t; diff --git a/src/lv_conf_checker.h b/src/lv_conf_checker.h index 0ff048b1c..219a02448 100644 --- a/src/lv_conf_checker.h +++ b/src/lv_conf_checker.h @@ -322,79 +322,41 @@ * FONT USAGE *===================*/ -/* More info about fonts: https://docs.littlevgl.com/#Fonts - * To enable a built-in font use 1,2,4 or 8 values - * which will determine the bit-per-pixel. Higher value means smoother fonts */ -#ifndef LV_USE_FONT_DEJAVU_10 -#define LV_USE_FONT_DEJAVU_10 4 +/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. + * The symbols are available via `LV_SYMBOL_...` defines + * More info about fonts: https://docs.littlevgl.com/#Fonts + * To create a new font go to: https://littlevgl.com/ttf-font-to-c-array + */ +#ifndef LV_FONT_ROBOTO_12 +#define LV_FONT_ROBOTO_12 0 #endif -#ifndef LV_USE_FONT_DEJAVU_10_LATIN_SUP -#define LV_USE_FONT_DEJAVU_10_LATIN_SUP 4 +#ifndef LV_FONT_ROBOTO_16 +#define LV_FONT_ROBOTO_16 1 #endif -#ifndef LV_USE_FONT_DEJAVU_10_CYRILLIC -#define LV_USE_FONT_DEJAVU_10_CYRILLIC 4 +#ifndef LV_FONT_ROBOTO_22 +#define LV_FONT_ROBOTO_22 0 #endif -#ifndef LV_USE_FONT_SYMBOL_10 -#define LV_USE_FONT_SYMBOL_10 4 -#endif - -#ifndef LV_USE_FONT_DEJAVU_20 -#define LV_USE_FONT_DEJAVU_20 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_20_LATIN_SUP -#define LV_USE_FONT_DEJAVU_20_LATIN_SUP 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_20_CYRILLIC -#define LV_USE_FONT_DEJAVU_20_CYRILLIC 4 -#endif -#ifndef LV_USE_FONT_SYMBOL_20 -#define LV_USE_FONT_SYMBOL_20 4 -#endif - -#ifndef LV_USE_FONT_DEJAVU_30 -#define LV_USE_FONT_DEJAVU_30 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_30_LATIN_SUP -#define LV_USE_FONT_DEJAVU_30_LATIN_SUP 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_30_CYRILLIC -#define LV_USE_FONT_DEJAVU_30_CYRILLIC 4 -#endif -#ifndef LV_USE_FONT_SYMBOL_30 -#define LV_USE_FONT_SYMBOL_30 4 -#endif - -#ifndef LV_USE_FONT_DEJAVU_40 -#define LV_USE_FONT_DEJAVU_40 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_40_LATIN_SUP -#define LV_USE_FONT_DEJAVU_40_LATIN_SUP 4 -#endif -#ifndef LV_USE_FONT_DEJAVU_40_CYRILLIC -#define LV_USE_FONT_DEJAVU_40_CYRILLIC 4 -#endif -#ifndef LV_USE_FONT_SYMBOL_40 -#define LV_USE_FONT_SYMBOL_40 4 -#endif - -#ifndef LV_USE_FONT_MONOSPACE_8 -#define LV_USE_FONT_MONOSPACE_8 1 +#ifndef LV_FONT_ROBOTO_28 +#define LV_FONT_ROBOTO_28 0 #endif /* Optionally declare your custom fonts here. * You can use these fonts as default font too * and they will be available globally. E.g. * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) \ + * LV_FONT_DECLARE(my_font_2) */ #ifndef LV_FONT_CUSTOM_DECLARE #define LV_FONT_CUSTOM_DECLARE #endif +/*Always set a default font from the built-in fonts*/ #ifndef LV_FONT_DEFAULT -#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/ +#define LV_FONT_DEFAULT &lv_font_roboto_16 #endif +/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ + /*================= * Text settings *=================*/ diff --git a/src/lv_misc/lv_font.h b/src/lv_misc/lv_font.h index 6787b3e39..c9166d876 100644 --- a/src/lv_misc/lv_font.h +++ b/src/lv_misc/lv_font.h @@ -118,6 +118,11 @@ static inline uint8_t lv_font_get_line_height(const lv_font_t * font_p) #define LV_FONT_DECLARE(font_name) extern lv_font_t font_name; +LV_FONT_DECLARE(lv_font_roboto_12) +LV_FONT_DECLARE(lv_font_roboto_16) +LV_FONT_DECLARE(lv_font_roboto_22) +LV_FONT_DECLARE(lv_font_roboto_28) + /*Declare the custom (user defined) fonts*/ #ifdef LV_FONT_CUSTOM_DECLARE LV_FONT_CUSTOM_DECLARE diff --git a/src/lv_misc/lv_font_fmt/lv_font_fmt_txt.c b/src/lv_misc/lv_font_fmt/lv_font_fmt_txt.c index 020973e51..98e90f693 100644 --- a/src/lv_misc/lv_font_fmt/lv_font_fmt_txt.c +++ b/src/lv_misc/lv_font_fmt/lv_font_fmt_txt.c @@ -78,9 +78,11 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * if(!gid) return false; int8_t kvalue = 0; + const lv_font_fmt_txt_glyph_dsc_t * gdsc_next = NULL; if(fdsc->kern_dsc) { uint32_t gid_next = get_glyph_dsc_id(font, unicode_letter_next); if(gid_next) { + gdsc_next = &fdsc->glyph_dsc[gid_next]; kvalue = get_kern_value(font, gid, gid_next); } } @@ -88,10 +90,10 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * /*Put together a glyph dsc*/ const lv_font_fmt_txt_glyph_dsc_t * gdsc = &fdsc->glyph_dsc[gid]; - uint32_t adw_w = gdsc->adv_w + ((int32_t)((int32_t)kvalue * fdsc->kern_scale) >> 4); - adw_w = (adw_w + (1 << 3)) >> 4; + uint32_t adv_w = gdsc->adv_w + ((int32_t)((int32_t)kvalue * fdsc->kern_scale) >> 4); + adv_w = (adv_w + (1 << 3)) >> 4; - dsc_out->adv_w = adw_w; + dsc_out->adv_w = adv_w; dsc_out->box_h = gdsc->box_h; dsc_out->box_w = gdsc->box_w; dsc_out->ofs_x = gdsc->ofs_x;