question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make fonts const in lvgl format

See original GitHub issue

As discussed here the lvgl fonts could be const with a few modifications.

@puzrin If you have some time could you modify the end of the generated fonts like this? See the parts added with #if LV_VERSION_CHECK(8, 0, 0).

/*--------------------
 *  ALL CUSTOM DATA
 *--------------------*/
#if LV_VERSION_CHECK(8, 0, 0)
/*Store all the custom data of the font*/
static  lv_font_fmt_txt_glyph_cache_t cache;
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
    .glyph_bitmap = gylph_bitmap,
    .glyph_dsc = glyph_dsc,
    .cmaps = cmaps,
    .kern_dsc = &kern_classes,
    .kern_scale = 16,
    .cmap_num = 2,
    .bpp = 4,
    .kern_classes = 1,
    .bitmap_format = 0,
#if LV_VERSION_CHECK(8, 0, 0)
    .cache = &cache
#endif
};

/*-----------------
 *  PUBLIC FONT
 *----------------*/

/*Initialize a public general font descriptor*/
#if LV_VERSION_CHECK(8, 0, 0)
const lv_font_t lv_font_montserrat_14 = {
#else
lv_font_t lv_font_montserrat_14 = {
#endif
    .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt,    /*Function pointer to get glyph's data*/
    .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt,    /*Function pointer to get glyph's bitmap*/
    .line_height = 16,          /*The maximum line height required by the font*/
    .base_line = 3,             /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
    .subpx = LV_FONT_SUBPX_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0)
    .underline_position = -1,
    .underline_thickness = 1,
#endif
    .dsc = &font_dsc           /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
puzrincommented, Mar 8, 2021

Released 1.5.0

1reaction
kisvegaborcommented, Mar 8, 2021

Works well, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fonts - LVGL documentation
To declare the font in a file, use LV_FONT_DECLARE(my_font_name) . To make the fonts globally available (like the builtin fonts), add them to ......
Read more >
Fonts - LVGL documentation
To declare a font in a file, use LV_FONT_DECLARE(my_font_name) . To make fonts globally available (like the built-in fonts), add them to LV_FONT_CUSTOM_DECLARE ......
Read more >
Make font cache optional - Feature request - LVGL Forum
Make font cache optional ... I realized that the lvgl font converter not only produces const structures, but also modifiable ones. Specifically ...
Read more >
Label (lv_label) - LVGL documentation
Parts and Styles¶. The label has only a main part, called LV_LABEL_PART_MAIN . It uses all the typical background properties and the text...
Read more >
Label (lv_label) - LVGL documentation
Why do I see nonsense colors on the screen? ... With lv_label_set_text_fmt(label, "Value: %d", 15) printf formatting can be used to set the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found