diff --git a/lv_objx/lv_label.c b/lv_objx/lv_label.c index fbea60f591..54bc728930 100644 --- a/lv_objx/lv_label.c +++ b/lv_objx/lv_label.c @@ -446,22 +446,8 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t } /*Calculate the x coordinate*/ - lv_coord_t x = 0; - uint32_t i = line_start; - uint32_t cnt = line_start; /*Count the letter (in UTF-8 1 letter not 1 byte)*/ - lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t letter; - while(cnt < index) { - cnt += lv_txt_encoded_size(&txt[i]); - letter = lv_txt_encoded_next(txt, &i); - /*Handle the recolor command*/ - if((flag & LV_TXT_FLAG_RECOLOR) != 0) { - if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) { - continue; /*Skip the letter is it is part of a command*/ - } - } - x += lv_font_get_width(font, letter) + style->text.letter_space; - } + lv_coord_t x = lv_txt_get_width(&txt[line_start], index, + font, style->text.letter_space, flag); if(ext->align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w;