Text Area + Rich Text or Simple HTML Tags

Hello

Is there any plans to support Rich text in LVGL Text Area?
Even if it was some simple mechanism to change specific properties of small parts of the text will be awesome.

image

Thank you
Fernando Henriques

Hi,

Recoloring should work in text area too.
image

ta1 = lv_textarea_create(lv_scr_act(), NULL);
lv_textarea_set_text(ta1, "A text #FF0000 in# a Text Area"); 
lv_label_set_recolor(lv_textarea_get_label(ta1), true);

is there a plan to support full rich text (also like html)?

I think this is unlikely for a number of reasons.

  • Additional logic is required to split label rendering into individually styled pieces.
  • There is no (easy and portable) way to dynamically transform a bitmap font (make it bolder/italic, etc.). FreeType gets around this by using vector fonts (TTFs) which store shape information and are thus much easier to transform.

The closest we would probably get to this is adding support for having multiple labels inside a container, similarly to how you can define multiple p or span elements in an HTML file.

I can imagine an extra widget (not lv_label) that styles and places every letter according to some format tags. The tags could tell the font, color, decoration, sub/superscript, etc of the fragment.

However, line wrapping and line-height calculation become quite complex especially if there are different font sizes. E.g.

image

hi,Will V8 support this widget?

It’s not on my roadmap. However, as always, contribution is very welcome. If you are interested in adding this widget please open an issue on GitHub to discuss it.

hi, Maybe I’ve already implemented the original version(base on v7).
sure, I will open an issue on GitHub to discuss and contribution it.
image

1 Like