diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index aa249d79f..0e7f024ae 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -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; } diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 26d792677..34678bdb5 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -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; /**********************