mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
font_fmt_txt: cache the last letter and its glyph
This commit is contained in:
parent
c52d8e8120
commit
f69dfce051
@ -113,6 +113,9 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
|
||||
|
||||
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
|
||||
|
||||
/*Check the chacge first*/
|
||||
if(letter == fdsc->last_letter) fdsc->last_glyph_id;
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < fdsc->cmap_num; i++) {
|
||||
|
||||
@ -147,9 +150,14 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
|
||||
}
|
||||
}
|
||||
|
||||
/*Update the cache*/
|
||||
fdsc->last_letter = letter;
|
||||
fdsc->last_glyph_id = glyph_id;
|
||||
return glyph_id;
|
||||
}
|
||||
|
||||
fdsc->last_letter = letter;
|
||||
fdsc->last_glyph_id = 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -184,6 +184,11 @@ typedef struct {
|
||||
* from `lv_font_fmt_txt_bitmap_format_t`
|
||||
*/
|
||||
uint16_t bitmap_format :2;
|
||||
|
||||
/*Cache the last letter and is glyph id*/
|
||||
uint32_t last_letter;
|
||||
uint32_t last_glyph_id;
|
||||
|
||||
}lv_font_fmt_txt_dsc_t;
|
||||
|
||||
/**********************
|
||||
|
Loading…
x
Reference in New Issue
Block a user