LVGL text size

Hi,

I am learning the stuff on vex screen with LVGL. When I am printing text, it seems really small to me.

Is it possible to make the text bigger?

here is my current code for it

lv_obj_t *
printtext( int x, int y, int width, int height, lv_color_t color, const char* text ) {
  lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);

  
  lv_style_t *style1 = (lv_style_t *)malloc( sizeof( lv_style_t ));
  lv_style_copy(style1, &lv_style_plain_color);   
  style1->text.color = color;

  

  
  
  lv_label_set_style(label,style1);
  lv_obj_set_pos(label, x, y);
  lv_obj_set_size(label, width, height);
  lv_label_set_text(label, text);

  
  
  
  return label;
}

I didn’t find here anything about it here. If I miss it, please share it.

1 Like

Haha, this is an issue that anyone using LVGL will eventually find themselves facing. I believe in newer versions, it is possible to change the font size natively. I assume you’re using PROS? If so, you will be stuck with LVGL 5.3, which is pretty old at this point and does not have any documentation available. For my team’s code this season, the Wayback Machine has proved invaluable, and a copy of the old documentation is available here.

I actually faced a similar issue while creating my team’s autonomous selector this season. I ended up solving this issue by creating a custom font with a custom size.

Steps to do this:

  1. Get a .ttf file of the font you want. I quite like Microsoft’s Selawik font, but I’m sure you could also find the ttf file for the default LVGL font.
  2. Upload said .ttf file to this website to convert it to C code. Make sure you tick the Convert as built-in font checkbox located at the bottom of the page. Don’t worry about any of the Unicode character stuff, just make sure you type all the characters you will need into the List text box (Don’t forget the space character!!!). Make sure you specify what size you want your font to be in the Height box.
  3. Press convert to download the resulting C code.
  4. Copy this file into the same folder as your UI code.
  5. Add the following code somewhere at the top of your UI code:
LV_FONT_DECLARE(my_font_name);
  1. To use this font, simply put the following code into your label’s style:
style.text.font = &my_font_name;

Hope this helps! Let me know if you need any more help, I’m currently thinking about creating an LVGL on the V5 Brain tutorial, which I may post sometime soon.

8 Likes

Everything went smoothly until I found this error.

I will really appreciate any tutorial on LVGL on vex brain.

lvgl.h is located at /include/display/lvgl.h.

Additionally, this page has a link to LVGL 5.3 examples.

4 Likes