bidi fixes for multi line text handling

This commit is contained in:
Gabor Kiss-Vamosi
2019-11-09 01:53:02 +01:00
parent 0130f3e5f2
commit 96b9114a5a
2 changed files with 5 additions and 4 deletions

View File

@@ -166,13 +166,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
i = 0; i = 0;
uint32_t letter; uint32_t letter;
uint32_t letter_next; uint32_t letter_next;
while(i < line_end - line_start) {
#if LV_USE_BIDI #if LV_USE_BIDI
char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1); char *bidi_txt = lv_draw_get_buf(line_end - line_start + 1);
lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0); lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, bidi_dir, NULL, 0);
#else #else
const char *bidi_txt = txt + line_start; const char *bidi_txt = txt + line_start;
#endif #endif
while(i < line_end - line_start) {
letter = lv_txt_encoded_next(bidi_txt, &i); letter = lv_txt_encoded_next(bidi_txt, &i);
letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL);
@@ -220,7 +221,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
letter_w = lv_font_get_glyph_width(font, letter, letter_next); letter_w = lv_font_get_glyph_width(font, letter, letter_next);
if(sel_start != 0xFFFF && sel_end != 0xFFFF) { if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i); int char_ind = lv_txt_encoded_get_char_id(bidi_txt, i + line_start);
/*Do not draw the rectangle on the character at `sel_start`.*/ /*Do not draw the rectangle on the character at `sel_start`.*/
if(char_ind > sel_start && char_ind <= sel_end) { if(char_ind > sel_start && char_ind <= sel_end) {
lv_area_t sel_coords; lv_area_t sel_coords;

View File

@@ -767,10 +767,10 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i), &is_rtl); logical_pos = lv_bidi_get_logical_pos(&txt[line_start], NULL, new_line_start - line_start, lv_obj_get_base_dir(label), lv_txt_encoded_get_char_id(bidi_txt, i), &is_rtl);
if (is_rtl) logical_pos++; if (is_rtl) logical_pos++;
#else #else
logical_pos = lv_encoded_get_char_id(bidi_txt, i); logical_pos = lv_txt_encoded_get_char_id(bidi_txt, i);
#endif #endif
return logical_pos + line_start; return logical_pos + lv_txt_encoded_get_char_id(txt, line_start) ;
} }
/** /**