Skip to content

Instantly share code, notes, and snippets.

@fridgerator
Created March 19, 2019 14:18
Show Gist options
  • Save fridgerator/40fb1f3e775d8c5b9f2781129b2792e1 to your computer and use it in GitHub Desktop.
Save fridgerator/40fb1f3e775d8c5b9f2781129b2792e1 to your computer and use it in GitHub Desktop.
lv_obj_t *main_container = lv_obj_create(parent, NULL);
lv_obj_set_size(main_container, 800, 480);
cairo_t *layout_context;
cairo_t *render_context;
cairo_surface_t *surface;
unsigned char* surface_data = NULL;
PangoFontDescription *desc;
PangoLayout *layout;
unsigned int *text_width;
unsigned int *text_height;
layout_context = create_layout_context ();
/* Create a PangoLayout, set the font and text */
layout = pango_cairo_create_layout (layout_context);
pango_layout_set_text (layout, label_text, -1);
desc = pango_font_description_from_string(FONT);
render_context = create_cairo_context(text_width, text_height, 4, &surface, &surface_data);
cairo_set_source_rgba (render_context, 1, 1, 1, 1);
pango_cairo_show_layout(render_context, layout);
char *img_data = cairo_image_surface_get_data(surface);
lv_obj_t *img = lv_img_create(main_container, NULL);
lv_img_set_src(img, &img_data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment