What do you want to achieve?
I want to create a checkbox where the checkbox indicator uses my font (BainsleyBold)
What have you tried so far?
I’ve already tested to confirm that I correctly converted the font including the U+2713 “✓” symbol. I tried using:
lv_checkbox_set_text(first_check_box, “✓”);
lv_obj_set_style_text_font(first_check_box, &BainsleyBold, LV_PART_MAIN);
lv_obj_set_style_text_font(first_check_box, &BainsleyBold, LV_PART_INDICATOR | LV_STATE_CHECKED);
This correctly displays the “✓” when using the text, but when I try to apply the custom font to the checkbox indicator itself, it shows a rectangle with a white border, as if the character cannot be found in the font.
Code to reproduce
lv_obj_t *first_check_box = lv_checkbox_create(first_control_card);
lv_checkbox_set_text(first_check_box, "✓");
lv_obj_set_size(first_check_box, 97, 97);
lv_obj_set_style_text_font(first_check_box, &BainsleyBold, LV_PART_MAIN);
lv_obj_set_style_text_font(first_check_box, &BainsleyBold, LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_coord_t box_size = 97;
lv_coord_t font_h = lv_font_get_line_height(&BainsleyBold);
lv_coord_t pad = (box_size - font_h) / 2;
lv_obj_set_style_pad_all(first_check_box, pad, LV_PART_INDICATOR);
lv_obj_update_layout(first_check_box);
Screenshot and/or video
Environment
- LVGL version: See
v9.2.2