How to set different font sizes in roller

Description

hello

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

What LVGL version are you using?

8.2

What do you want to achieve?

Set different font for 'LV_PART_MAIN ’ and ‘LV_PART_SELECTED’

What have you tried so far?

Code to reproduce

Hi, Team, @kisvegabor , @embeddedt
I am using ‘roller’, i want set different font for 'LV_PART_MAIN ’ and ‘LV_PART_SELECTED’, but i get a strange effect,the ‘LV_PART_SELECTED’ can not be centered vertically, please help!
Best Regards,
Allen

lv_obj_t *roller1 = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller1,
                    "January\n"
                    "February\n"
                    "March\n"
                    "April\n"
                    "May\n"
                    "June\n"
                    "July\n"
                    "August\n"
                    "September\n"
                    "October\n"
                    "November\n"
                    "December",
                    LV_ROLLER_MODE_INFINITE);

    lv_roller_set_visible_row_count(roller1, 4);
    lv_obj_center(roller1);
    lv_obj_set_style_text_font(roller1, &lv_font_montserrat_48, LV_PART_SELECTED);
    lv_obj_set_style_text_font(roller1, &lv_font_montserrat_14, LV_PART_MAIN);

Screenshot and/or video

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

Actually it’s centered, but the letter in “December” doesn’t have any lower parts. If you select “January” where “y” has a lower part you will see that it’s center aligned.

I replaced English with numbers, but the problem still exists. @kisvegabor
image

It’s due to the same reason. The number doesn’t have a “lower part” either.

However I’ve found workaround:

    lv_obj_t * label = lv_obj_get_child(roller1, 0);
    lv_obj_set_style_pad_top(label, 10, 0);
1 Like

Thank you very much, it really worked, and it’s a great job.
image

1 Like