From 2efa6dce78604cdf422ff233a99f7dd5f06b821c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 18 Oct 2021 15:41:33 +0200 Subject: [PATCH] fix(label) fix clipped italic letters fixes: #2559 --- src/widgets/lv_label.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/widgets/lv_label.c b/src/widgets/lv_label.c index dbd400b3d..a13421c13 100644 --- a/src/widgets/lv_label.c +++ b/src/widgets/lv_label.c @@ -757,6 +757,15 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_label_revert_dots(obj); lv_label_refr_text(obj); } + else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) { + /* Italic or other non-typical letters can be drawn of out of the object. + * It happens if box_w + ofs_x > adw_w in the glyph. + * To avoid this add some extra draw area. + * font_h / 4 is an empirical value. */ + const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); + lv_coord_t font_h = lv_font_get_line_height(font); + lv_event_set_ext_draw_size(e, font_h / 4); + } else if(code == LV_EVENT_SIZE_CHANGED) { lv_label_revert_dots(obj); lv_label_refr_text(obj);