1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

font: update kern space format

This commit is contained in:
Gabor Kiss-Vamosi 2019-05-01 18:08:56 +02:00
parent cc97e114c2
commit 469157ebd9
3 changed files with 15 additions and 6 deletions

View File

@ -83,8 +83,8 @@ static const uint8_t lv_font_dejavu_20_glyph_bitmap[] = {
static const lv_font_kern_t kern_0031[] = { static const lv_font_kern_t kern_0031[] = {
{.next_unicode = 0x0033, .space = 3 << 4}, {.next_unicode = 0x0033, .space = LV_FONT_SET_WIDTH(8, 0), .space_sign = LV_FONT_KERN_POSITIVE},
{.next_unicode = 0x0000} /*Trailing*/ {.next_unicode = 0x0000} /*Trailing*/
}; };
/*Store the glyph descriptions*/ /*Store the glyph descriptions*/

View File

@ -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) 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; uint32_t i;
for(i = 0; dsc.kern_table[i].next_unicode != 0; i++) { for(i = 0; dsc.kern_table[i].next_unicode != 0; i++) {
if((uint32_t)dsc.kern_table[i].next_unicode == letter_next) { 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; break;
} }
} }

View File

@ -41,8 +41,10 @@ extern "C" {
/*One element of a kerning table*/ /*One element of a kerning table*/
typedef struct { typedef struct {
int32_t next_unicode :23; uint32_t next_unicode :23;
int32_t space :9; /*5 integer, 4 fractional*/
uint32_t space :8; /*5 integer, 4 fractional*/
uint32_t space_sign :1; /*0: space positive; 1: space negative*/
}lv_font_kern_t; }lv_font_kern_t;
/*Describe the properties of a glyph*/ /*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_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_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 * ADD BUILT IN FONTS