From ecbd2ba4cd399831e991b5e6ff780289fbddaf99 Mon Sep 17 00:00:00 2001 From: liamHowatt <30486941+liamHowatt@users.noreply.github.com> Date: Wed, 10 Apr 2024 02:43:50 -0400 Subject: [PATCH] feat(font): add lv_font_glyph_release_draw_data api to release glyph data (#6052) Co-authored-by: Benign X <1341398182@qq.com> --- .github/workflows/check_style.yml | 1 + src/draw/lv_draw_label.c | 5 ++--- src/font/lv_font.c | 9 +++++++++ src/font/lv_font.h | 7 +++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_style.yml b/.github/workflows/check_style.yml index 7623a0191..4b69b1a39 100644 --- a/.github/workflows/check_style.yml +++ b/.github/workflows/check_style.yml @@ -18,6 +18,7 @@ jobs: with: repository: szepeviktor/astyle path: astyle + ref: v3.4.10 - name: Install astyle run: | cd astyle/build/gcc/ diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index 81a11e87b..e7c9d86d3 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -438,8 +438,7 @@ static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, dsc->g = &g; cb(draw_unit, dsc, NULL, NULL); - if(g.resolved_font && font->release_glyph) { - font->release_glyph(font, &g); - } + lv_font_glyph_release_draw_data(&g); + LV_PROFILER_END; } diff --git a/src/font/lv_font.c b/src/font/lv_font.c index 6cbd8e0d1..de486b7ea 100644 --- a/src/font/lv_font.c +++ b/src/font/lv_font.c @@ -50,6 +50,15 @@ const void * lv_font_get_glyph_bitmap(lv_font_glyph_dsc_t * g_dsc, uint32_t lett return font_p->get_glyph_bitmap(g_dsc, letter, draw_buf); } +void lv_font_glyph_release_draw_data(lv_font_glyph_dsc_t * g_dsc) +{ + const lv_font_t * font = g_dsc->resolved_font; + + if(font != NULL && font->release_glyph) { + font->release_glyph(font, g_dsc); + } +} + bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next) { diff --git a/src/font/lv_font.h b/src/font/lv_font.h index 77feee414..d7d9c832a 100644 --- a/src/font/lv_font.h +++ b/src/font/lv_font.h @@ -133,6 +133,13 @@ const void * lv_font_get_glyph_bitmap(lv_font_glyph_dsc_t * g_dsc, uint32_t lett bool lv_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next); +/** + * Release the bitmap of a font. + * @note You must call @lv_font_get_glyph_dsc to get @g_dsc (@lv_font_glyph_dsc_t) before you can call this function. + * @param g_dsc the glyph descriptor including which font to use, which supply the glyph_index and the format. + */ +void lv_font_glyph_release_draw_data(lv_font_glyph_dsc_t * g_dsc); + /** * Get the width of a glyph with kerning * @param font pointer to a font