How lvgl MessageBox display Chinese?

Description

What MCU/Processor/Board and compiler are you using?

F1C100S

What LVGL version are you using?

V8.3.6

What do you want to achieve?

When I click switch then pop up MessageBox, MessageBox display Chinese, choose 确定 or 取消, so switch turn on or turn off.(“确定” in English is sure, “取消” in English is cancle.)

What have you tried so far?

See lvgl official sample and try to modify it, I think in MessageBox for 确定 or 取消 need set font, but I not see like this sample. I run below code that I provide, result is I see box in 确定 and 取消 position.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

static void event_cb(lv_event_t* e)
{
    lv_obj_t* obj = lv_event_get_current_target(e);
    LV_LOG_USER("Button %s clicked", lv_msgbox_get_active_btn_text(obj));
}

void lv_example_msgbox_1(void)
{
    //static const char* btns[] = { "Apply", "Close", "" };
    static const char* btns[] = { "确定", "取消", "" };

    //lv_obj_t* mbox1 = lv_msgbox_create(NULL, "Hello", "This is a message box with two buttons.", btns, true);
    lv_obj_t* mbox1 = lv_msgbox_create(NULL, NULL, "This is a message box with two buttons.", btns, true);
    lv_obj_add_event_cb(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
    lv_obj_center(mbox1);
}

static void event_handler(lv_event_t* e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t* obj = lv_event_get_target(e);
    if (code == LV_EVENT_VALUE_CHANGED) {
        LV_UNUSED(obj);
        lv_example_msgbox_1();
    }
}

Call function is below:

    ui_Switch1 = lv_switch_create(ui_Screen1);
    lv_obj_set_width(ui_Switch1, 100);
    lv_obj_set_height(ui_Switch1, 42);
    lv_obj_set_x(ui_Switch1, -329);
    lv_obj_set_y(ui_Switch1, -192);
    lv_obj_set_align(ui_Switch1, LV_ALIGN_CENTER);
    lv_obj_add_event_cb(ui_Switch1, event_handler, LV_EVENT_ALL, NULL);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

MessageBox--Display

2 Likes

Maybe you should take a look at lvgl font documentation here is, I read and followed the instructions above and was able to display my Vietnamese font.

1 Like

@OWlchanMagican I see your screen, it’s good, I will see the link that in your answer.

Thank you very much.

1 Like

Hi OWlchanMagican,
I am working on a project to support Vietnamese on an LCD screen using the lvgl library, but I still don’t quite understand how to add Vietnamese fonts to achieve the same font as you are displaying. Could you please provide more detailed instructions on some steps? I really appreciate your enthusiastic help. (I am using the software at Online font converter - TTF or WOFF fonts to C array | LVGL and also using the Montserrat font. I’m not sure if I have set up the parameters incorrectly, but I am unable to create Vietnamese fonts like you.)

@kisvegabor hi , why I can’t edit my post or modify my post or delete my post?
I can do nothing.

I don’t know to be honest.
Maybe there is a timeout, so you cannot edit the posts older than some time.

@kisvegabor What? I see that you are administrator of this website.

See below picture:

Yes, I am, and I checked your profile in an admin view but haven’t seen anything extraordinary.

That’s why I said that maybe it’s a mechanism of the Forum engine (Discourse) that I’m not aware of.

@kisvegabor Sorry for my poor English, what does ‘extraordinary’ mean that in you said is “extraordinary power”(Chinese is 特权) or “abnormal situation”(Chinese is 异常情况) ?Thank you.

I mean I haven’t seen anything strange in your profile. However, it seem you can already edit your posts.

@kisvegabor First thank you for your explain about “extraordinary”. But you said “However, it seem you can already edit your posts.”, I’m confused about it, because I can’t find edit button.

See below picture:

But this icon indicates that you have edited your posts:

Even this last one:

I just found this: Post can't be edited - support - Discourse Meta

Now the limit tis set to 1 day.

@kisvegabor Ok, thank you for you provided link, I know.