Here is the correct way to find text width in pixels
lv_point_t p;
_lv_txt_ap_proc(my_str, ctx_text);
_lv_txt_get_size(&p, ctxi_text, my_font, 0, 0, LV_COORD_MAX, LV_TXT_FLAG_EXPAND);
p.x contains the total width in pixels.
LVGL contains a lot of good resources, but need to dig.
Excellent work.