diff --git a/lv_misc/lv_txt.c b/lv_misc/lv_txt.c index 5c8e869f3..6e094a1a7 100644 --- a/lv_misc/lv_txt.c +++ b/lv_misc/lv_txt.c @@ -199,6 +199,8 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, width += letter_space; } + width -= letter_space; /*Trim the last letter space because there is no letter after it*/ + /*Trim closing spaces. Important when the text is aligned to the middle */ for(i = length - 1; i > 0; i--) { if(txt[i] == ' ') {