German umlauts?

Hello,

has anybody already used german umlauts? Any hints how to get them displayed?

Take the fontconverter (https://lvgl.io/tools/fontconverter)
Create a font file for including in C source from a preferred TTF font
Set an appropriate style for using this font.
Assign this style to where you need the german text.
Write your german text (source file is UTF8).

That should do it.

Sorry, but I’ somewhat lost on this.

The original Montserrat fonts DO contain german umlauts. Where did they go lost?

When I convert those fonts from github, then the fontawesome symbols will be lost? Or is there a way to combine two fonts? In the style, I can choose only ONE font. So all the symbols and letters and umlauts have to be in the same font?

Only the basic ASCII character set (and some symbols) are included in the default fonts, otherwise the flash consumption would be huge. The expectation is that you will re-convert the font for your project if you need additional characters.

Yes. However, our converter lets you merge fonts together (that’s how we are able to mix FontAwesome symbols with Montserrat characters).

1 Like

I don’t buy this point for two reasons:

  1. Fonts can be activated/deactivated at compile time individually.
  2. Do you really think those seven german umlauts use more flash than the “font with normal range + Hebrew, Arabic, Perisan letters and all their forms” or the “CJK Radicals” which are already built in? It is OK to include almost all of the world, but including those seven umlauts would overflow the flash? Really?

But it won’t let me add just those seven letters to the existing built-in fonts. I’d have to re-generate everything from scratch and possibly mess up something that has already been done properly for the built-in fonts.

Maybe it would make sense to “merge” fonts at runtime:
Add multiple font styles to an object. If a glyph is not found in the first style, look it up in the next one. Or maybe a style might have multiple font settings. like this:

lv_style_set_text_font(&my_style, LV_STATE_DEFAULT, &lv_font_montserrat_28);
lv_style_set_text_font(&my_style, LV_STATE_DEFAULT, &lv_font_awesome_28);
lv_style_set_text_font(&my_style, LV_STATE_DEFAULT, &lv_font_my_language_28);
lv_style_set_text_font(&my_style, LV_STATE_DEFAULT, &lv_font_another_language_28);

This way it would be possible to just add those letters for your favorite language without duplicating the whole basic character set. Please note that the basic ASCII characters and also fontawesome are all duplicated in the persian/hebrew/arabic/CJK fonts.

Side-benefit would be that e.g. fontawesome would not be included/generated for every font, but only once. This would help to reduce flash size and maintenance effort.

PS: This “merge” functionality is just a quick-n-dirty idea, far from being thought properly through to the end. Possibly it would make more sense to have such a merge functionality in the font-subsystem instead of the style subsystem.

Maybe something like

lv_font_t lv_merge_fonts (int number_of_fonts, ...);

static lv_font_t my_merged_font_28
    = lv_merge_fonts (4,
        &lv_font_montserrat_28,
        &lv_font_awesome_28,
        &lv_font_my_language_28,
        &lv_font_another_language_28,
);

or something.

@kisvegabor @puzrin Any thoughts on this?

The problem with adding a few language-specific characters is that a lot of languages have a few special characters and that together needs significant memory. E.g.:

Spain: 
ÁéÉíÍñÑóÓúÚüÜ¿¡

Romanian:
ĂăÂâÎîȘșȚț

Hngarian:
áÁéÉíÍüÜűŰóÓöÖőŐ 

Slovak:
áäčďéíĺľňóôŕšťúýž

You can re-generate all fonts with this script and add local modification.

We have dropped the idea of merging (maybe unrelated) fonts because it could be difficult to arrange the metrics run time.

jw@kiste:~/lvgl$ (cd src/lv_font/ && ../../scripts/built_in_font/generate_all.py)
Generating 8 px
sh: 1: ./built_in_font_gen.py: not found
[ many errors deleted... ]
jw@kiste:~/lvgl$ (cd scripts/built_in_font/ && ../../scripts/built_in_font/generate_all.py)
Generating 8 px
sh: 1: lv_font_conv: not found
sed: can't read lv_font_montserrat_8.c: No such file or directory
[ many errors deleted... ]

How is this script meant to be run?

This should work:

npm install -g lv_font_conv # Node.js and npm need to be installed first
cd scripts/built_in_font
./generate_all.py

Thanks,

unfortunately, now I get syntax error:

Generating 8 px                                                                              
/m/b/home/jw/.local/lib/node_modules/lv_font_conv/node_modules/argparse/argparse.js:222      
    } catch {}                                                                               
            ^                                                                                
                                                                                             
SyntaxError: Unexpected token {                                                              
    at createScript (vm.js:80:10)                                                            
    at Object.runInThisContext (vm.js:139:10)                                                
    at Module._compile (module.js:616:28)                                                               
    at Object.Module._extensions..js (module.js:663:10)                                      
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/m/b/home/jw/.local/lib/node_modules/lv_font_conv/lib/cli.js:6:21)
sed: lv_font_montserrat_8.c kann nicht gelesen werden: Datei oder Verzeichnis nicht gefunden

Looks like your Node.js version may be out of date; it requires Node 10 and newer.

would it be possible to add characters after the fact?

something like:
lv_font_add_char(font, char, bytearray)? or lv_font_add_chars(font, chars, bytearray)

this would also be handy for MicroPython, where users probably play with more than one program.

PS. I created a feature request for it, see https://forum.lvgl.io/t/add-characters-to-a-font-on-the-fly/6542