From fde3ee73af8fe4427c6aedcaafdbed1eb2972bbc Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 11 Jul 2018 18:46:35 +0200 Subject: [PATCH] lv_txt_get_width: don't trim the closing spaces because it would result unwanted text wrap --- lv_misc/lv_txt.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lv_misc/lv_txt.c b/lv_misc/lv_txt.c index ce73bf889..d388157be 100644 --- a/lv_misc/lv_txt.c +++ b/lv_misc/lv_txt.c @@ -198,17 +198,7 @@ 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] == ' ' || txt[i] == '\n' || txt[i] == '\r') { - width -= lv_font_get_width(font, txt[i]); - width -= letter_space; - } else { - break; - } - } + width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */ } return width;