Montserrat fonts issues - Squareline Studio project in Arduino Giga R1 with ArduinoGigaDisplayShield

Hi everybody,

I successfully exported and ran a project on the Arduino Giga R1 with the Arduino Giga Display Shield. However, the major issue I encountered is regarding lv_font_montserrat_. In the lv_conf.h file, I’ve enabled the correct font, but they don’t seem to work, except for montserrat_14. I ended up modifying a screen.c file, changing all different sizes to 14. What could I be doing wrong?
The lv_font_montferrat_14 works even if the value in the lv_conf.h file is set to 0.

this is the error solved changing all size number with 14 in the screen.c file.

lv_font_montserrat_20’ undeclared (first use in this function); did you mean ‘lv_font_montserrat_18’?
lv_obj_set_style_text_font(ui_MonoCurrentPanelLabel, &lv_font_montserrat_20, LV_PART_MAIN| LV_STATE_DEFAULT);

SquareLine Studio, when an Arduino TFT_eSPI project is created and exported, sets the lv_conf.h file correctly by enabling the fonts used by the SquareLine GUI project. But you’re right. I too tried to build a project in Arduino IDE with the same Giga board and display and it seems to ignore the setting in lv_conf.h (neither lv_conf_template.h, for that matter). We’ll keep an eye on a possible best solution, for the moment the ‘undefined referece error’ during compilation disappears if you remove the ‘#ifdef’ guards around the wished LV_FONT_DECLARE(lv_font_montserrat_xx) in lv_font.h. This is a fast and dirty test and the linker still misses the font at the end of compilation. Proper solution in the Arduino IDE project needs to be found…

so basically, what you’re telling me is that at the moment the compilation error problem can be solved, but will we graphically always display the montserrat_14 character?

The problem still needs further investigation for proper solution. We’ll try to help you to find the proper Arduino-IDE setting, maybe meanwhile Arduino IDE gurus will have an idea here at the forum.

Thank you,
I’ll wait any possible solution!!

Sometimes setting ‘flat export’ in SquareLine Studio Project Settings solves Arduino-IDE build problems (as suggested here for example: 'ui_Button1' undeclared - Arduino compiler throws this error after renaming buttons - #4 by JGB )
In this case it seemed not to solve the problem.
Arduino IDE is made with simplicity in mind from user perspective, but at the same time this means it expects specific folders and files in place (‘src’/‘libraries’) and with certain extensions (‘.cpp’,‘.h’), to do things fairly automatically, and when problems like this occur it’s needed to check what it does under the hood. I found a forum topic at stackoverflow about the possible quirks and solutions, maybe a good starting point to understad Arduino IDE’s build-chain: c++ - How do I add cpp file to an arduino project? - Stack Overflow
Our investigation will not end here, but if seasoned Arduino-IDE users have further tips about the possible issue it’s still welcome…Maybe a look at LVGL-forum (this is more of an LVGL-related question) will reveal some solutions, e.g. with keywords ‘arduino montserrat’ I found a testing for this case (but no solution): 'lv_font_montserrat_48' was not declared - #3 by kisvegabor - General discussion - LVGL Forum .
While not obvious, I guess the Arduino projects can be built in commandline too with Arduino-SDK, and there are directions for CMake builds too which are probably more efficient, flexible and more transparent than Arduino-IDE’s simple GUI…

Thank you for your response. I tried some of the things you recommended without success. I would like to send you my project (just the sketch to load the graphic interface on the display), but I can’t because I’m new to the forum. Can someone help me solve the problem?


No need to send your project as I could reproduce the issue in Arduino-IDE with the same board and display settings. We still want to help you as at the same time we want our Arduino board-template to work well out-of-the-box with custom fontsizes, just need some timeframe. As soon we find a proper solution or a workaround I’ll post it here.

Thank you Hermit! :pray:

I played around again with Arduino IDE 1.8.19 and a label with montserrat16 font, creating new Arduino-IDE projects with different LVGL-versions (8.3.6,8.3.11,9.0.0), gradually increasing the project complexities. Starting with new fresh sketch folders worked fine in this regard, both with LVGL installed to the sketch-folder by the Tools / Manage Libraries dialog (where LVGL version is selectable) and with LVGL created by SquareLine Studio template-project export. (The selected board was still Giga.)
There are some important things for Arduino-IDE to work: lvgl folder should be in libraries folder, lv_conf.h should be there too, the main .ino file should be in a folder named the same as the (base)name-part of the .ino file, and all these folders (libraries and the folder of the .ino) should be in the (preferably freshly created) sketch folder, which must be set in the Arduino-IDE preferences for the project. (This is where the libraries needed by the project get installed by the library manager. But you can put them manually there if they have the / json settings for Arduino-IDE.)

When I disabled montserrat16 support in lv_conf.h the compilation gave the error, when I set it back, the compilation was fine again.
The surprising problem arose when I started to include GigaDisplay related libraries and then modified lv_conf.h by disabling montserrat16. The compilation failed with colordepth/byteswap-match problems, and if overridden (commented out) the error in ui.c, compilation halted with the missing montserrat16 problem, even if the font was re-enabled in lv_conf.h, as if the lv_conf.h was not seen anymore by the builder. The only solution to compile again was to delete the GigaDisplay includes from the .ino file, reopen Arduino-IDE with the project and initiate a fresh build. (It throws the incremental build cache only when reopened, according to forums.)
Maybe lv_conf.h was cached in Arduino-IDE and it was not read from ‘library’ folder ever after, until the library-inclusions were deleted from the .ino file and the whole IDE was reopened. Conclusion: there’s something with the Giga Display Shield related libraries vs Arduino IDE caching/build system that renders lv_conf.h unseen. I hope we could help, but our investigation ends here for now, SquareLine Studio exports the projects fine.

Thank you for your time! I’ll try to do that, and I’ll let you know!
Thank you again

You’re welcome. I guess a possible solution for you is to create a completely new sketch folder with your intended content (the project) with a proper lv_conf.h (having the necessary fonts enabled) and avoid modifying lv_conf.h after the GigaDisplay headers are included in the main .ino file, while the project in Arduino-IDE is opened. This might be a workaround for this ‘black-magic’ behind the scene. But the best would be to find the real cause in the GigaDisplay-ArduinoIDE vs lv_conf.h constellation. I suspect that those display-libraries include an internal lv_conf.h somewhere that overrides the project’s own, based on the symptoms, but it’s just a wild guess. At this point I guess it’s worth a question at Arduino forum.

EDIT: As it turns out after several trials, for me the inclusion (with #include "xxx") of an Arduino Video header file that was missing from the project’s library folders, caused the problem. One would expect an error from the builder that a file to include is missing, but instead this gave the missing montserrat16/lv_conf.h. error, and did so just after a modification of lv_conf.h, which was misleading. This was something with the incremental build engine: A fresh build should give error, or if it’s set to just give a warning for missing file, the project should still rebuild fine after modifying lv_conf.h… Maybe this gives a pointer of what to expect from Arduino-IDE’s builder, and that a fresh restart of a project can save the situation sometimes.