From 00149a0e90ec2bd16acbfc78615d84f084039cec Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 2 Dec 2008 17:30:57 +0100 Subject: [PATCH] draw: fix text alignment on small width Signed-off-by: Julien Danjou --- draw.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/draw.c b/draw.c index 3a33904c..b1680145 100644 --- a/draw.c +++ b/draw.c @@ -406,17 +406,19 @@ draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrap * face */ y = area.y + (ctx->height - ext.height + 1) / 2 + pdata->margin.top; - switch(pdata->align) - { - case AlignCenter: - x += (area.width - ext.width) / 2; - break; - case AlignRight: - x += area.width - ext.width; - break; - default: - break; - } + /* only honors alignment if enough space */ + if(ext.width < area.width) + switch(pdata->align) + { + case AlignCenter: + x += (area.width - ext.width) / 2; + break; + case AlignRight: + x += area.width - ext.width; + break; + default: + break; + } if(pdata->shadow.offset) {