Skip to content

Commit

Permalink
add subpx and compressed fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Nov 25, 2019
1 parent 5f33746 commit 5f2e5e4
Show file tree
Hide file tree
Showing 5 changed files with 5,897 additions and 17 deletions.
17 changes: 10 additions & 7 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
#define LV_FONT_ROBOTO_22 0
#define LV_FONT_ROBOTO_28 0

/* Demonstrate special features */
#define LV_FONT_ROBOTO_12_SUBPX 1
#define LV_FONT_ROBOTO_28_COMPRESSED 1 /*bpp = 3*/

/*Pixel perfect monospace font
* http://pelulamu.net/unscii/ */
#define LV_FONT_UNSCII_8 0
Expand All @@ -327,6 +331,12 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
* but with > 10,000 characters if you see issues probably you need to enable it.*/
#define LV_FONT_FMT_TXT_LARGE 0

/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
*/
#define LV_FONT_SUBPX_BGR 0

/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_font_user_data_t;

Expand All @@ -344,7 +354,6 @@ typedef void * lv_font_user_data_t;
/*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS " ,.;:-_"


/* If a word is at least this long, will break wherever "prettiest"
* To disable, set to a value <= 0 */
#define LV_TXT_LINE_BREAK_LONG_LEN 12
Expand Down Expand Up @@ -381,12 +390,6 @@ typedef void * lv_font_user_data_t;
# define lv_vsnprintf vsnprintf
#endif /*LV_SPRINTF_CUSTOM*/

/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
*/
#define LV_SUBPX_BGR 0

/*===================
* LV_OBJ SETTINGS
*==================*/
Expand Down
25 changes: 16 additions & 9 deletions src/lv_conf_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@
#define LV_FONT_ROBOTO_28 0
#endif

/* Demonstrate special features */
#ifndef LV_FONT_ROBOTO_12_SUBPX
#define LV_FONT_ROBOTO_12_SUBPX 1
#endif
#ifndef LV_FONT_ROBOTO_28_COMPRESSED
#define LV_FONT_ROBOTO_28_COMPRESSED 1 /*bpp = 3*/
#endif

/*Pixel perfect monospace font
* http://pelulamu.net/unscii/ */
#ifndef LV_FONT_UNSCII_8
Expand Down Expand Up @@ -455,6 +463,14 @@
#define LV_FONT_FMT_TXT_LARGE 0
#endif

/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
*/
#ifndef LV_FONT_SUBPX_BGR
#define LV_FONT_SUBPX_BGR 0
#endif

/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/

/*=================
Expand All @@ -475,7 +491,6 @@
#define LV_TXT_BREAK_CHARS " ,.;:-_"
#endif


/* If a word is at least this long, will break wherever "prettiest"
* To disable, set to a value <= 0 */
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
Expand Down Expand Up @@ -532,14 +547,6 @@
#endif
#endif /*LV_SPRINTF_CUSTOM*/

/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
*/
#ifndef LV_SUBPX_BGR
#define LV_SUBPX_BGR 0
#endif

/*===================
* LV_OBJ SETTINGS
*==================*/
Expand Down
2 changes: 1 addition & 1 deletion src/lv_draw/lv_draw_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv

uint8_t bg_rgb[3] = {LV_COLOR_GET_R(*vdb_buf_tmp), LV_COLOR_GET_G(*vdb_buf_tmp), LV_COLOR_GET_B(*vdb_buf_tmp)};

#if LV_SUBPX_BGR
#if LV_FONT_SUBPX_BGR
LV_COLOR_SET_B(res_color, (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[2] * (255 - font_rgb[0]))) >> 8);
LV_COLOR_SET_R(res_color, (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[0] * (255 - font_rgb[2]))) >> 8);
#else
Expand Down
Loading

0 comments on commit 5f2e5e4

Please sign in to comment.