From 0261969930471c61b52f3d3142ce50d19ad3abb1 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 1 Oct 2008 14:07:30 +0200 Subject: [PATCH] draw: allow text to be on multiple lines Signed-off-by: Julien Danjou --- draw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/draw.c b/draw.c index 86a98176..fb9a6c31 100644 --- a/draw.c +++ b/draw.c @@ -393,7 +393,9 @@ draw_text(draw_context_t *ctx, font_t *font, pango_units_from_double(area.width - (pdata->margin.left + pdata->margin.right))); + pango_layout_set_height(ctx->layout, pango_units_from_double(area.height)); pango_layout_set_ellipsize(ctx->layout, PANGO_ELLIPSIZE_END); + pango_layout_set_wrap(ctx->layout, PANGO_WRAP_WORD_CHAR); pango_layout_set_attributes(ctx->layout, pdata->attr_list); pango_layout_set_font_description(ctx->layout, font->desc); pango_layout_get_pixel_extents(ctx->layout, NULL, &ext); @@ -402,7 +404,7 @@ draw_text(draw_context_t *ctx, font_t *font, /* + 1 is added for rounding, so that in any case of doubt we rather draw * the text 1px lower than too high which usually results in a better type * face */ - y = area.y + (ctx->height - font->height + 1) / 2 + pdata->margin.top; + y = area.y + (ctx->height - ext.height + 1) / 2 + pdata->margin.top; switch(pdata->align) {