Unable to use Devnagiri font

What MCU/Processor/Board and compiler are you using?

Esp32 Intended
Using Simulator on linux currently

What do you want to achieve?

Display any Indian font converted from ttf file

What have you tried so far?

Downloaded NotoSans font from Google

Converted it using online convertor
and used it in the code

I got blank output when using hindi text

Try flipping the value of LV_USE_ARABIC_PERSIAN_CHARS. We’ve had some reports that turning it on/off can break certain character sets.

If it still doesn’t work please show a screenshot of the settings you used to convert the font.

Everything is much simpler: these characters are not in standard fonts. And so it is drawn in version 6 normally. Although I do not understand, you can understand something here or not.


Hi @embig71
I don’t understand by what you mean from it is drawn in version 6.
Which font did you use for that text? It is rendering perfectly.


I meant that RTL languages (for example, Persian or Hebrew) are not needed for display. I do not propose switching to version 6, I just use it. I made a font from the standard Windows Arial Uni, but I have my own renderer. I can try to connect the resulting font to version 7, but I’m sure that everything will work fine.

Woah thank you so much.

Can you share the settings you used for the font?

Range is 0x0900-0x097F right?
Can you please upload the converted file for me to try out?

As for the range, probably yes. The fact is that I do not control the setting of ranges. The script scans used strings and renders glyphs for all characters found. So now only symbols from the beginning of the declaration of rights have been generated.lv_font_tahoma.c (61.9 KB) lv_font_tahoma.h (676 Bytes)

Hey I tried the tacoma font

Still can’t get it working

It seems that everything works, at first glance. How are you trying to use the font? Can be set as default. And you can change the style of the object.

// In lv_conf.h
#if (0)
#define LV_THEME_DEFAULT_FONT_SMALL         &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_NORMAL        &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SUBTITLE      &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_TITLE         &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SMALL         &lv_font_tahoma
#define LV_THEME_DEFAULT_FONT_NORMAL        &lv_font_tahoma
#define LV_THEME_DEFAULT_FONT_SUBTITLE      &lv_font_tahoma
#define LV_THEME_DEFAULT_FONT_TITLE         &lv_font_tahoma

static void font_test(void) {
    lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
    lv_obj_set_width (label1, 300);
    //lv_label_set_long_mode(label1, LV_LABEL_LONG_BREAK);     /*Break the long lines*/
    lv_label_set_recolor(label1, true);                      /*Enable re-coloring by commands in the text*/
    lv_label_set_align(label1, LV_LABEL_ALIGN_LEFT);
    lv_obj_align (label1, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 20);
    lv_label_set_text(label1, "#0000ff सर्वे मानवाः स्वतन्त्राः समुत्पन्नाः वर्तन्ते अपि च,#\n गौरवदृशा अधिकारदृशा च समानाः\n #ff0000 एव वर्तन्ते। #एते सर्वे चेतना-तर्क-शक्तिभ्यां सुसम्पन्नाः\n सन्ति। अपि च, सर्वेऽपि बन्धुत्व-भावनया परस्परं व्यवहरन्तु।");

Hi again Thanks

I got it working but as I was afraid there are problems with ligatures. After closely looking the text you have entered vs the output text you can see the difference. Some supposed to be joined letters have been rendered separately and incorrectly.
You can see right from the first word the differences. Hindi language has many cases of joint words. I have a working solution of this on raspberry pi using QT library. After searching more QT uses FreeType engine. How do I setup this engine and directly use ttf fonts?

Do you have any another solution in mind?
You can refer here the difficulty in adding support for Hindi manually

As India has many languages it is almost impossible to compile all rules
Is there any way to use ttf directly?

As far as I know, the normal support of languages with different letter styles depending on the position in the word and ligatures is a difficult task. Arabic has the same problems, plus RTL. And using Freetype here will not help. Here we also need a software layer like HarfBuzz, for example. An example of using Freetype for rendering in the target program is in the https://github.com/lvgl/lv_lib_freetype repository. Only the proper use of Freetype (with glyph caching) is also a rather difficult task.

Is there anyway you can use QT in this library to render text? QT does an amazing job with all languages

I do not know much about the internal architecture of Qt, but in my opinion, there is a very high coherence of the code oriented to the slot signal architecture. And the license is generally not consistent with MIT.

By the time you’ve brought Qt into your project, you might as well use it for everything. Also, I very much doubt Qt can fit on the smaller devices we target (i.e. <256KB RAM, <512KB Flash).

I’ve just fixed the issue related to LV_USE_ARABIC_PERSIAN_CHARS.
If you have the proper characters in the font and use that font with the label it should display it.

However, if there are some special things like position-related character replace then further development is required on LVGL’s side. As it was already mentioned this kind of character replacement already works for Arabic/Persian language so probably we can handle the Indian language there too.

Here is the relevant source code: https://github.com/lvgl/lvgl/blob/master/src/lv_misc/lv_txt_ap.c

What do you think?

How to set it up to use the correction?
But every language will have different set of substitution rules so they need to be added here?

Some links related to the issue

Can you check out the code they’ve used to render Devnagiri?

If you already found it can you link the relevant files?