Description
I used dropdown to display Chinese. It seems work bad. English options works well.But Chinese options did not display.
What MCU/Processor/Board and compiler are you using?
visual stdio 2019
What LVGL version are you using?
v8.2.0
What do you want to achieve?
I want use dropdown widget display Chinese.
What have you tried so far?
I have used labels display chinese well.
Code to reproduce
YaHei is fine.I will attach it below.
void forum()
{
dd_axis = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options(dd_axis, "倾斜\n"//"Dip\n"
"开关伞\n"//"Umb\n"
"旋转");//"Rot");
lv_obj_align(dd_axis, LV_ALIGN_TOP_LEFT, 10, 10);
lv_obj_set_style_text_font(dd_axis, &YaHei, 0);
}
Screenshot and/or video
YaHei.c (144.6 KB)
Add the following lines to your code:
lv_obj_t* list = lv_dropdown_get_list(dd_axis);
lv_obj_set_style_text_font(list, &YaHei, 0);
To change the style of a list (part of dropdown list), you need to get the list itself. Then apply all style changes to it.
Thank you for all this .
I used a font_tool that convert source code file to get font file like YaHei.c.
As you see. The “﹀” is missed.
I add the symbol from keyboard inside win10 to source code file.
void forum()
{
dd_axis = lv_dropdown_create(lv_scr_act());
lv_obj_t* list = lv_dropdown_get_list(dd_axis);
lv_dropdown_set_options(dd_axis, "倾斜\n"//"Dip\n"
"开关伞\n"//"Umb\n"
"旋转\n"//"Rot");
"%﹀");
lv_obj_align(dd_axis, LV_ALIGN_TOP_LEFT, 10, 10);
lv_obj_set_style_text_font(list, &YaHei, 0);
lv_obj_set_style_text_font(dd_axis, &YaHei, 0);
}
And I use font tool to input source code file and export YaHei.c .
But It seems like the symbol is not equal the LV_SYMBOL_DOWN.
I want to know how could make this symbol appear.
jr_ol
March 3, 2022, 10:21am
#4
Hello, I would like to ask a question, how to display Chinese in the center normally, my Chinese font will always be displayed at the top, even though I have set it to display in the center.
You can add FontAwesome5-Solid+Brands+Regular to your font with needed range:
All lvgl symbols you can found in lv_symbol_def.h
My font with LV_SYMBOL_DOWN (0xF078) looks:
You can use on your list of dropdown list:
lv_obj_set_style_text_align(list, LV_TEXT_ALIGN_CENTER, 0);
But that don’t works, text on button of dropdown list displayed at the left:
lv_obj_set_style_text_align(dd_axis, LV_TEXT_ALIGN_CENTER, 0);