feat(bidi): prioritize RTL over LTR in base direction detection (#9779)

This commit is contained in:
SamuraiAnderson
2026-03-02 16:23:06 +08:00
committed by GitHub
parent 9be625b9ec
commit 17587650b3
+5 -1
View File
@@ -109,14 +109,18 @@ lv_base_dir_t lv_bidi_detect_base_dir(const char * txt)
{
uint32_t i = 0;
uint32_t letter;
bool found_ltr = false;
while(txt[i] != '\0') {
letter = lv_text_encoded_next(txt, &i);
lv_base_dir_t dir;
dir = lv_bidi_get_letter_dir(letter);
if(dir == LV_BASE_DIR_RTL || dir == LV_BASE_DIR_LTR) return dir;
if(dir == LV_BASE_DIR_RTL) return LV_BASE_DIR_RTL;
if(dir == LV_BASE_DIR_LTR) found_ltr = true;
}
if(found_ltr) return LV_BASE_DIR_LTR;
/*If there were no strong char earlier return with the default base dir*/
if(LV_BIDI_BASE_DIR_DEF == LV_BASE_DIR_AUTO) return LV_BASE_DIR_LTR;
else return LV_BIDI_BASE_DIR_DEF;