From b3bfa3c58b2934897aacebf48e806256186f8cb6 Mon Sep 17 00:00:00 2001 From: iDalink <934367813@qq.com> Date: Mon, 26 Oct 2020 19:01:32 +0800 Subject: [PATCH] lv_label effect area clip line space (#1866) Co-authored-by: Dalink --- src/lv_widgets/lv_label.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index eacba00e0..e50e711e3 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -1383,13 +1383,22 @@ static void lv_label_refr_text(lv_obj_t * label) } else { lv_point_t p; + lv_coord_t y_overed; p.x = lv_area_get_width(&txt_coords) - (lv_font_get_glyph_width(font, '.', '.') + letter_space) * LV_LABEL_DOT_NUM; /*Shrink with dots*/ p.y = lv_area_get_height(&txt_coords); - p.y -= p.y % - (lv_font_get_line_height(font) + line_space); /*Round down to the last line*/ - p.y -= line_space; /*Trim the last line space*/ + y_overed = p.y % + (lv_font_get_line_height(font) + line_space); /*Round down to the last line*/ + if (y_overed >= lv_font_get_line_height(font)) { + p.y -= y_overed; + p.y += lv_font_get_line_height(font); + } + else { + p.y -= y_overed; + p.y -= line_space; + } + uint32_t letter_id = lv_label_get_letter_on(label, &p);