diff options
| author | foswret | 2026-04-30 23:50:37 -0500 |
|---|---|---|
| committer | foswret | 2026-04-30 23:50:37 -0500 |
| commit | e291d28cdb37534ad5b22c1eff94a9b389edd2ad (patch) | |
| tree | 75aaccee1d05ff91eb24f6ca15a7cff530ccf5cf /src/draw.c | |
| parent | 6f21b2bc0af8325420980e6c75eb71d39551072e (diff) | |
implement wrapper function for pango text drawing
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; +} |
