Lv_roller_set_align(),unable to set center align

Description

  • Use different font files roller unable to set center align.

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

arm

What LVGL version are you using?

v7.5.0

What do you want to achieve?

Set roller center align.

What have you tried so far?

lv_roller_set_align, have no effect.

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 lv_style_t style;
	lv_style_init(&style);
	lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_100);
	lv_style_set_radius(&style, LV_STATE_DEFAULT, 0);
	lv_style_set_border_width(&style, LV_STATE_DEFAULT, 0);
	lv_style_set_text_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
	lv_style_set_text_line_space(&style, LV_STATE_DEFAULT, 46);
	lv_style_set_text_font(&style, LV_STATE_DEFAULT, &Apeman_bd_26height);
	//lv_style_set_text_font(&style, LV_STATE_DEFAULT, &SF_Pro_Text_Bold_23px);
	lv_style_set_text_opa(&style, LV_STATE_DEFAULT, LV_OPA_20);

	lv_obj_t *roller = lv_roller_create(lv_scr_act(), NULL);
	lv_obj_add_style(roller, LV_ROLLER_PART_BG, &style);
	lv_obj_add_style(roller, LV_ROLLER_PART_SELECTED, &style);
	lv_roller_set_options(roller, "TEXT1\nTEXT2\nTEXT3", LV_ROLLER_MODE_NORMAL);
	lv_roller_set_auto_fit(roller, false);
	lv_roller_set_visible_row_count(roller, 4);
	lv_obj_set_size(roller, 150, 200);
	lv_obj_align(roller, NULL, LV_ALIGN_CENTER, 0, 0);

image

The last option is center align,why not the others.
Please give me some advice, best regards.

Hi,
i tryed with my version 7.11.0 with lv_font_montserrat36 and i have the text perfectly
aligned, try to update to the latest version.

Dear andre,
In version 7.5.0,some fonts are perfectly aligned as well. I just want to know why the font I’m using doesn’t align. Can you try it out with this font? I have uploaded the resource.

I tried to set the left alignment and it worked perfectly, but center-aligned and right-aligned don’t work.

I found the problem,it’s because of the switch ‘\n’. This problem can be turned off.