1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
int fill_bg(cairo_t *c, double w, double h) {
cairo_set_source_rgb (c, 255.0, 255.0, 255.0);
cairo_rectangle(c, 0, 0, w, h);
cairo_fill(c);
return 0;
}
int draw_text (cairo_t *c, double x, double y, char *text) {
#define FONT "Sans Bold 27"
PangoLayout *layout;
PangoFontDescription *desc;
// Create a PangoLayout, setting font & text
layout = pango_cairo_create_layout(c);
desc = pango_font_description_from_string(FONT);
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
cairo_set_source_rgb (c, 0.0, 0.0, 0.0);
pango_layout_set_text(layout, text, -1);
//pango_cairo_update_layout (c, layout);
cairo_move_to (c, x, y);
pango_cairo_show_layout (c, layout);
g_object_unref(layout);
return 0;
}
|