diff --git a/src/lv_fonts/lv_font_dejavu_20.c b/src/lv_fonts/lv_font_dejavu_20.c index 786e152cf..c7a77ca49 100644 --- a/src/lv_fonts/lv_font_dejavu_20.c +++ b/src/lv_fonts/lv_font_dejavu_20.c @@ -83,8 +83,8 @@ static const uint8_t lv_font_dejavu_20_glyph_bitmap[] = { static const lv_font_kern_t kern_0031[] = { - {.next_unicode = 0x0033, .space = 3 << 4}, - {.next_unicode = 0x0000} /*Trailing*/ + {.next_unicode = 0x0033, .space = LV_FONT_SET_WIDTH(8, 0), .space_sign = LV_FONT_KERN_POSITIVE}, + {.next_unicode = 0x0000} /*Trailing*/ }; /*Store the glyph descriptions*/ diff --git a/src/lv_misc/lv_font.c b/src/lv_misc/lv_font.c index b72c87216..9de3fa9ba 100644 --- a/src/lv_misc/lv_font.c +++ b/src/lv_misc/lv_font.c @@ -42,7 +42,7 @@ static int32_t lv_font_codeCompare(const void * pRef, const void * pElement); **********************/ /** - * Initialize the fonts + * Initialize the font module */ void lv_font_init(void) { @@ -143,7 +143,11 @@ uint8_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_ uint32_t i; for(i = 0; dsc.kern_table[i].next_unicode != 0; i++) { if((uint32_t)dsc.kern_table[i].next_unicode == letter_next) { - w += dsc.kern_table[i].space; + if(dsc.kern_table[i].space_sign == LV_FONT_KERN_POSITIVE) { + w += dsc.kern_table[i].space; + } else { + w -= dsc.kern_table[i].space; + } break; } } diff --git a/src/lv_misc/lv_font.h b/src/lv_misc/lv_font.h index 63325c881..3c04ae404 100644 --- a/src/lv_misc/lv_font.h +++ b/src/lv_misc/lv_font.h @@ -41,8 +41,10 @@ extern "C" { /*One element of a kerning table*/ typedef struct { - int32_t next_unicode :23; - int32_t space :9; /*5 integer, 4 fractional*/ + uint32_t next_unicode :23; + + uint32_t space :8; /*5 integer, 4 fractional*/ + uint32_t space_sign :1; /*0: space positive; 1: space negative*/ }lv_font_kern_t; /*Describe the properties of a glyph*/ @@ -202,6 +204,9 @@ bool lv_font_get_glyph_dsc_plain(const lv_font_t * font, lv_font_glyph_dsc_t * d #define LV_FONT_GET_WIDTH_INT(_w) (_w >> LV_FONT_WIDTH_FRACT_DIGIT) #define LV_FONT_GET_WIDTH_FRACT(_w) (_w & ((1 << LV_FONT_WIDTH_FRACT_DIGIT) -1)) +#define LV_FONT_KERN_POSITIVE 0 +#define LV_FONT_KERN_NEGATIVE 1 + /********************** * ADD BUILT IN FONTS