The source below compared and output the fonts made by squreline and tiny ttf.
lv_obj_t* ui_example_label = NULL;
lv_obj_t* ui_example2_label = NULL;
lv_obj_t * ui_ScreenTest;
lv_style_t medium_font_style;
void lv_example_tiny_ttf_test(void)
{
lv_disp_t * dispp = lv_disp_get_default();
lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
false, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);
ui_ScreenTest = lv_obj_create(NULL);
lv_obj_clear_flag(ui_ScreenTest, LV_OBJ_FLAG_SCROLLABLE); /// Flags
lv_obj_set_style_bg_color(ui_ScreenTest, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_ScreenTest, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_example_label = lv_label_create(ui_ScreenTest);
ui_example2_label = lv_label_create(ui_ScreenTest);
lv_obj_set_width(ui_example_label, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_example_label, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_example_label, 136);
lv_obj_set_y(ui_example_label, 240);
//lv_obj_set_align(ui_example_label, LV_ALIGN_TOP_MID);
lv_label_set_text(ui_example_label, "89");
lv_obj_set_style_text_color(ui_example_label, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_example_label, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_example_label, &ui_font_FontMeduum120, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_width(ui_example2_label, LV_SIZE_CONTENT); /// 1
lv_obj_set_height(ui_example2_label, LV_SIZE_CONTENT); /// 1
lv_obj_set_x(ui_example2_label, 136);
lv_obj_set_y(ui_example2_label, 240);
lv_label_set_text(ui_example2_label, "00");
lv_obj_set_style_text_color(ui_example2_label, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(ui_example2_label, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(ui_example2_label, ui_font_FontMeduum120_2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_disp_load_scr(ui_ScreenTest);
}
I use 272x480 lcd.
The ui_example_label (“89”) uses font made by squreline,
ui_example_label2 (“00”) used font made by tiny ttf.
The x and y coordinates of ui_example_label (“89”) and ui_example2_label were set to 136, 240.
As shown in the picture below, ui_example_label (“89”) appears to have x and y coordinates of 136, 240,
The ui_example_label2 (“89”) has an x-coordinate of 136, and the y-coordinate goes down by about 20 pixels.
Why does it go down 20 pixels?
What is the reason?