From 243145d8c93b20cce0354921061763ccb53ec4b7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 20 Dec 2020 13:21:06 +0100 Subject: [PATCH] add arabic processin to to window title and lv_dropdown_add_option --- CHANGELOG.md | 2 ++ src/lv_widgets/lv_dropdown.c | 17 +++++++++++++---- src/lv_widgets/lv_win.c | 13 +++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d7670681..99609bfb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Bugfixes - fix(draw_rect) free buffer used for arabic processing +- fix(win) arabic process the title of the window +- fix(dropdown) arabic process the option in lv_dropdown_add_option ## v7.8.1 (Plannad at 15.12.2020) diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 446206d69..d0ebc0efd 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -303,7 +303,12 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint32_t pos /*Allocate space for the new option*/ size_t old_len = (ext->options == NULL) ? 0 : strlen(ext->options); - size_t ins_len = strlen(option); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + size_t ins_len = strlen(option) + 1; +#else + size_t ins_len = _lv_txt_ap_calc_bytes_cnt(option) + 1; +#endif + size_t new_len = ins_len + old_len + 2; /* +2 for terminating NULL and possible \n */ ext->options = lv_mem_realloc(ext->options, new_len + 1); LV_ASSERT_MEM(ext->options); @@ -331,9 +336,13 @@ void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option, uint32_t pos char * ins_buf = _lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */ LV_ASSERT_MEM(ins_buf); if(ins_buf == NULL) return; - strcpy(ins_buf, option); - if(pos < ext->option_cnt) - strcat(ins_buf, "\n"); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + strcpy(ins_buf, options); +#else + _lv_txt_ap_proc(option, ins_buf); +#endif + if(pos < ext->option_cnt) strcat(ins_buf, "\n"); + _lv_txt_ins(ext->options, _lv_txt_encoded_get_char_id(ext->options, insert_pos), ins_buf); _lv_mem_buf_release(ins_buf); diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index 3e4a5f3f8..e087e2d19 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -258,11 +258,20 @@ void lv_win_set_title(lv_obj_t * win, const char * title) lv_win_ext_t * ext = lv_obj_get_ext_attr(win); - ext->title_txt = lv_mem_realloc(ext->title_txt, strlen(title) + 1); +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 + size_t len = strlen(title) + 1; +#else + size_t len = _lv_txt_ap_calc_bytes_cnt(title) + 1; +#endif + + ext->title_txt = lv_mem_realloc(ext->title_txt, len + 1); LV_ASSERT_MEM(ext->title_txt); if(ext->title_txt == NULL) return; - +#if LV_USE_ARABIC_PERSIAN_CHARS == 0 strcpy(ext->title_txt, title); +#else + _lv_txt_ap_proc(title, ext->title_txt); +#endif lv_obj_invalidate(ext->header); }