A simple requirement really, but its vexing me. I need to print a £ symbol on my displays.
I’m using Visual Studio 2022 with Visual Micro for Arduino.
I have read lots of articles on the Forum and have read on creating my own font, which I cant seem to fathom and was wondering do I really need to create a custom font for a pound sign?
Thank you, but in the end I did what the manual said and created a new font… Begrudgingly… as I only needed a £ sign!
For anyone else, steps as follows:
1) Visit Google to choose and download your font as follows (Montserrat in my case):
Change the font size and click “Get Font”
Save into a location and unzip the file, ensuring the font you need is listed
2) Visit LVGL Font Converter
Name: I used the same name as the font I downloaded, but with a small description change Font Size: Choose the font size you required, for LVGL Default it is 14 BPP: Select 4 bits per pixel Fall Back: I left blank Output: C File Browse Font to upload your chosen font Range:" This is a key part, to ensure you capture the symbols you need, in my case I needed
32-126,0xA3 (ASCII + Pound Sign £)
So enter 32-126,0xA3 only
**Then select: ** “Submit”
3) Copy your new downloaded font file to the same folder as your INO / sketch location
4) Edit the lv_conf file in the section FONT USAGE as follows:
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(INSERT YOU FONT NAME HERE)
5) Here is a code snippet on how I used the new font:
/* Declare the custom bold font */
LV_FONT_DECLARE(Montserrat_Regular_GBP_Bold);
/* Add a title above the chart */
lv_obj_t* chart_title = lv_label_create(lv_scr_act());
lv_label_set_text(chart_title, "Stock Performance");
lv_obj_set_style_text_font(chart_title, &Montserrat_Regular_GBP_Bold, LV_PART_MAIN); // Use bold font
lv_obj_align(chart_title, LV_ALIGN_OUT_TOP_MID, 5, 5); // Position it above the chart
/* Label the X-axis */
lv_obj_t* x_axis_label = lv_label_create(lv_scr_act());
lv_label_set_text(x_axis_label, "Time");
lv_obj_set_style_text_font(x_axis_label, &Montserrat_Regular_GBP_Bold, LV_PART_MAIN); // Use bold font
lv_obj_align_to(x_axis_label, chart, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); // Position below the chart
/* Label the Y-axis */
lv_obj_t* y_axis_label = lv_label_create(lv_scr_act());
lv_label_set_text(y_axis_label, "\xC2\xA3");
lv_obj_set_style_text_font(y_axis_label, &Montserrat_Regular_GBP_Bold, LV_PART_MAIN); // Use bold font
lv_obj_align_to(y_axis_label, chart, LV_ALIGN_OUT_LEFT_MID, -10, 0); // Position to the left of the chart
What is important, is that something wasnt right between my IDE encoding and the file, so I had to specify this line to get the £ sign: