lvgl / lv_utils

Convert images or system fonts to C arrays. Written for LVGL embedded GUI library
https://littlevgl.com
54 stars 38 forks source link

Feedback usage font converter #7

Closed Zaltora closed 5 years ago

Zaltora commented 6 years ago

Hi, i recently used your tools to get a better font and symbol for small display. Impressive tools to get directly a standard ttf to generate any font possible. My remarks: I think we should add more built-in font to match different screen type. I found the "Terminus" which is well suited to small oled screens for example.

I do not think I did the right thing to add a font. I directly modify the files lv_font.c, lv_font.h to integrate my fonts as if they were already included in lvgl. What is the simply way ? Or maybe a user can not just call some "registration function" in this own program ? ( Range / Array / ...)

I noticed that the online tools do not generate the case of non-ASCII characters. I add manually:

#if LV_TXT_UTF8
    .unicode_first = 61440, First Unicode letter in this font * /
    .unicode_last = 62190, Last Unicode letter in this font * /
#else
    .unicode_first = 192, First Unicode letter in this font * /
    .unicode_last = 241, Last Unicode letter in this font * /
#endif

I had a problem when generating my symbols, I had to directly modify the sources at the end of the file from:

    .unicode_list = symbol_unicode_list,    /*List of unicode characters*/
    .get_bitmap = lv_font_get_bitmap_sparse,    /*Function pointer to get glyph's bitmap*/
    .get_width = lv_font_get_width_sparse,  /*Function pointer to get glyph's width*/

to:

    .unicode_list = NULL, / * List of unicode characters * /
    .get_bitmap = lv_font_get_bitmap_continuous, / * Function pointer to get glyph's bitmap * /
    .get_width = lv_font_get_width_continuous, / * Function pointer to get glyph's width * /

Another minor remark. Associate fonts of different size as for example to associate "lv_font_dejavu_20" and "lv_font_symbol_10" will make appear another part of another symbol because fonts files don't get the same pixel height size. Is it worth adding a size control according to the range of fonts registration? e.g: 32-126 => size 14 192-241 => size 18 it is maybe not a necessary upgrade.

Thank you for this tool :)

kisvegabor commented 6 years ago

Hi,

Thank you for the feedback!

Using the generated fonts

There is a short guide on the font converter's page: "How to use the generated fonts in LittlevGL?" Have you tried it?

Symbols

This part

#if LV_TXT_UTF8
    .unicode_first = 61440, First Unicode letter in this font * /
    .unicode_last = 62190, Last Unicode letter in this font * /
#else
    .unicode_first = 192, First Unicode letter in this font * /
    .unicode_last = 241, Last Unicode letter in this font * /
#endif

is a special case because the symbols are located at different locations with and without UTF8 support. As it's a special case the generator doesn't adds it automatically. It's the same with ..unicode_list, .get_bitmap and .get_width.

It seems useful to add checkbox like "Generate symbol font" which could make these changes automatically. What do you think?

Zaltora commented 6 years ago

I see the documentation but i don' no where put my generated files. Tell me if i am right Can be possible to add the font file in my app, then use a lvgl function to register this whitout need to change the font file. or I need just put this in my app LV_FONT_DECLAER(my_font_name) ? That disturb me to see #include "../lv_font.h" into the generated font.

Automatic changes with a button will be great with a warning if is not possible (when too much symbol for ASCII). Maybe add some notes about it too. :)

kisvegabor commented 6 years ago

You can copy it anywhere in you project. You just have to declare it (LV_FONT_DECLAER) where you want to use it. No modification required in the files

That disturb me to see #include "../lv_font.h" into the generated font.

If you generate a built-in font then the converter supposes that you will use it as part of LittelvGL. But for not built-in fonts you should see #include "lvgl/lv_misc/lv_font.h"

Automatic changes with a button will be great with a warning if is not possible (when too much symbol for ASCII). Maybe add some notes about it too. :)

As the mapping of built in symbols is hard coded in lv_symbol_defs.h it is not possible to show warning because if you generate a compatible built-in font than you should use this mapping. But if you use other symbol mapping (not the as in lv_symbol_defs.h) than it's up to you where to place it but then they won't be compatible with the defines in lv_symbol_defs.h.

stale[bot] commented 5 years ago

This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

embeddedt commented 5 years ago

This issue is very old. Please open a new one to continue the discussion.