From 03f919a0fbb7ff4397768437037de9423d57f409 Mon Sep 17 00:00:00 2001 From: QC Date: Sun, 9 Nov 2014 12:35:12 +0100 Subject: [PATCH] Fix center mode. --- source/textbox.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/textbox.c b/source/textbox.c index 26fea7f8..3cbcb293 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -252,7 +252,8 @@ void textbox_draw ( textbox *tb ) x = ( tb->w - line_width ) * PANGO_SCALE; } else if ( tb->flags & TB_CENTER ) { - x = ( PANGO_SCALE * ( tb->w - line_width ) ) / 2; + int tw = textbox_get_font_width ( tb ); + x = ( PANGO_SCALE * ( tb->w - tw ) ) / 2; } y = ( PANGO_SCALE * ( textbox_get_width ( tb ) - textbox_get_font_width ( tb ) ) ) / 2; // Render the layout. @@ -261,7 +262,7 @@ void textbox_draw ( textbox *tb ) // draw the cursor if ( tb->flags & TB_EDITABLE ) { - XftDrawRect ( draw, &tb->color_fg, cursor_x + SIDE_MARGIN, SIDE_MARGIN, cursor_width, font_height ); + XftDrawRect ( draw, &tb->color_fg, x / PANGO_SCALE + cursor_x + SIDE_MARGIN, SIDE_MARGIN, cursor_width, font_height ); } XftDrawRect ( draw, &tb->color_bg, tb->w, 0, 0, tb->h );