diff options
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -1,8 +1,32 @@ #include <cairo/cairo.h> +#include <pango/pangocairo.h> -int fill_bg(cairo_t *c, double x, double y) { +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, x, y); + 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; +} |
