remove duplicate lv_txt_get_width code in lv_label

This commit is contained in:
Brian Pugh
2019-01-06 18:16:42 -08:00
parent 4b2cd9030c
commit 5f11d67812
+2 -16
View File
@@ -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;