diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-12-27 21:57:29 +0000 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-12-27 21:57:29 +0000 |
commit | a68d64edca4f67df49b9499272319cad93d38bbe (patch) | |
tree | e1f5084d006257713090bb7a2dc1f91976b91e7c /src/render.c | |
parent | fb69111748d9d4eba92024799421ee2573418d15 (diff) |
Draw from callbacks
Diffstat (limited to 'src/render.c')
-rw-r--r-- | src/render.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/render.c b/src/render.c index e02c9ec..6a88116 100644 --- a/src/render.c +++ b/src/render.c @@ -59,6 +59,35 @@ static void render_glyph_box(cairo_t *cr, struct wrap_box *box) } +static void render_surface_box(cairo_t *cr, struct wrap_box *box) +{ + double ascd; + double x, y; + + cairo_save(cr); + + ascd = pango_units_to_double(box->ascent); + + x = 0.0; + y = -ascd; + cairo_user_to_device(cr, &x, &y); + + cairo_new_path(cr); + cairo_rectangle(cr, 0.0, -ascd, pango_units_to_double(box->width), + pango_units_to_double(box->height)); + + if ( box->surf == NULL ) { + cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 1.0); + fprintf(stderr, "Null surface box"); + } else { + cairo_identity_matrix(cr); + cairo_set_source_surface(cr, box->surf, x, y); + } + + cairo_fill(cr); + cairo_restore(cr); +} + static void render_image_box(cairo_t *cr, struct wrap_box *box, ImageStore *is, enum is_size isz) @@ -157,6 +186,10 @@ static void render_boxes(struct wrap_line *line, cairo_t *cr, ImageStore *is, render_image_box(cr, box, is, isz); break; + case WRAP_BOX_SURFACE: + render_surface_box(cr, box); + break; + case WRAP_BOX_NOTHING : break; |