lvgl / lv_lib_freetype

Interface to FreeType to generate font bitmaps run time
https://lvgl.io
MIT License
55 stars 19 forks source link

this demo does not work for me #2

Closed nezen closed 4 years ago

nezen commented 4 years ago

Hi kisvegabor, thanks for your work. I've been trying to display resizable custom font on run time with littlevgl and freetype on my PC Sim but no luck so far. I just simply apply this demo to littlevgl demo, the freetype part seems to work since I can get a glyph bitmap from my font, but nothing displays. Any advice for my problem would be appreciated, thanks !

kisvegabor commented 4 years ago

Hi,

Hm, that's strange. Please enable LV_USE_LOG and LV_USE_PRINTF in lv_conf.h.

Which simulator do you use?

nezen commented 4 years ago

Hi,

Hm, that's strange. Please enable LV_USE_LOG and LV_USE_PRINTF in lv_conf.h.

Which simulator do you use?

Hi kisvegabor, I just folllowed the guide from https://github.com/littlevgl/lv_sim_eclipse_sdl, so I should be using SDL2 on ubuntu. The simulator project works fine alone. To provide more details, I've uploaded my code snippets and logs to https://github.com/nezen/littlevgl_demo, please take a look and see if it helps, thanks !

kisvegabor commented 4 years ago

I've tested it like this and it worked for me:


lv_freetype_init();

static lv_font_t font1;
lv_freetype_font_init(&font1, "./lv_lib_freetype/arial.ttf", 32);

static lv_style_t style1;
lv_style_copy(&style1, &lv_style_plain);
style1.text.font = &font1;

lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_style(label, LV_LABEL_STYLE_MAIN, &style1);
lv_label_set_text(label, "Hello world");

Could you try it?

nezen commented 4 years ago

I've tested it like this and it worked for me:

lv_freetype_init();

static lv_font_t font1;
lv_freetype_font_init(&font1, "./lv_lib_freetype/arial.ttf", 32);

static lv_style_t style1;
lv_style_copy(&style1, &lv_style_plain);
style1.text.font = &font1;

lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_style(label, LV_LABEL_STYLE_MAIN, &style1);
lv_label_set_text(label, "Hello world");

Could you try it?

I'd tried but my problem still exists. Would you mind sharing all your test codes?

nezen commented 4 years ago

Update: I have updated my littlevgl version to 6.1.2 and half of the label displays, still working on it. helloworld

kisvegabor commented 4 years ago

I've just added my code to the freetype_test branch.

nezen commented 4 years ago

freetype_test works perfectly for me, Thanks for your time!

kisvegabor commented 4 years ago

Great! :)