How to properly render fonts?


I am trying to render a custom font on a 256x64 display with 4-bits per pixel. When I display text using the font, it shows the text with the font, but it renders with some glitches: it looks jarred or something, not sure how to describe it.

It also glitches a lot when updating the text: (1)

See how the D and the numbers glitch when updating the label to the same text.

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

NXP MIMXRT1011 with arm gcc 10.3.1

What LVGL version are you using?


What do you want to achieve?

Nicer smooth rendering.

What have you tried so far?

I know that I don’t have issues drawing to my display. I tried rendering images and animations and they look very smooth. So I am confident that it is not a hardware issue or an issue with my flush function, etc.

I checked that the font doesn’t have issues in the simulator, it renders just fine.

I tried enabling/disabling antialiasing, subpixel rendering. I also tried regenerating the fonts with different bits-per-pixel and with/without subpix rendering. I still got glitchy text.

Code to reproduce

The following codes illustrates how I’m using the font in my project. This code works in the simulator and renders properly, but it does not look the same in my device.

#include "lvgl.h"


static lv_style_t text_style_regular;
static lv_obj_t * m_content_text;

void test_run(void) {
    lv_style_set_text_font(&text_style_regular, &inter_medium_35);
    lv_style_set_text_color(&text_style_regular, lv_color_black());
    lv_style_set_align(&text_style_regular, LV_ALIGN_TOP_LEFT);
    lv_style_set_width(&text_style_regular, 480);

    m_content_text = lv_label_create(lv_scr_act());
    lv_obj_add_style(m_content_text, &text_style_regular, LV_STATE_DEFAULT);
    lv_label_set_text(m_content_text, "This is a very very long text that should be constantly scrolling");
    lv_label_set_long_mode(m_content_text, LV_LABEL_LONG_SCROLL_CIRCULAR);

Find the font file attached (generated with 4 bpp and subpix rendering):
inter_medium_35.c (803.0 KB)


I found the issue. See:

1 Like