Text attributes: bold, italic, underline

Description

Is it possible to use bold, italic or underlined text in LVGL? It is possible to use Freetype library during a render, but it will be much easier if I could use these styles in LVGL.

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

Any

What do you want to achieve?

Apply bold/italic/underline style to text

What have you tried so far?

I see no option for controlling it anywhere.

Code to reproduce

N/A

Screenshot and/or video

N/A

You need a separate font for bold and italic, as it changes the bitmaps themselves.

Underlines can be applied by setting the text_decor style property to LV_TEXT_DECOR_UNDERLINE.

Is it possible to use multiple fonts on the same widget?

1 Like

It depends on what widget. On a button I think you could put multiple labels side by side, each with their own font. With a single label, it wouldn’t be possible to use multiple fonts.

I want to create terminal emulator using LVGL + Freetype + libtsm. The main idea is to let user use virtual keyboard with terminal emulator. There is fbkeyboard project, but it covers part of screen and user can not see what is shown on bottom of screen. Also there is AROMA Filemanager project with terminal emulator feature, but it is abandoned, heavy and has no full vte100 support. libtsm has callback which lets me draw the screen symbol by symbol. I think I will have a set of labels. Maybe I will make using freetype optional. I still do not know how it will look like on devices with different DPI.

Without FreeType you’ll never be able to guarantee 100% smooth visuals as we use fixed-size bitmap fonts. Even if you had a set of sizes for “common” devices it could break if someone tried it on a really HiDPI screen.

1 Like

I think it will be usable for recovery reasons (like CWM/TWRP). PostmarketOS still uses fbcon on Android devices after reflashing kernel. And also it can be used as one of shells in userspace on touchscreen devices, for recovery purposes (like AROMA Filemanager+terminal). One of advantages of LVGL-based programs is binary size, they can be easily packed into ramdisk.

1 Like