From e9fc76ec1091b47b92aeb2143d6159dacf3b70b2 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 29 Jul 2009 21:26:55 -0700 Subject: [PATCH] output: Fix vertical alignment of text to a baseline in chart output. This makes labels on pie charts look better, for example. --- src/output/charts/plot-chart.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/output/charts/plot-chart.c b/src/output/charts/plot-chart.c index 8d499866..04c10c4d 100644 --- a/src/output/charts/plot-chart.c +++ b/src/output/charts/plot-chart.c @@ -122,14 +122,20 @@ chart_label (cairo_t *cr, int horz_justify, int vert_justify, else cairo_rel_move_to (cr, -width / 2.0, 0); } - if (vert_justify != 't') + if (vert_justify == 'x') + { + int baseline_pango = pango_layout_get_baseline (layout); + double baseline = (double) baseline_pango / PANGO_SCALE; + cairo_rel_move_to (cr, 0, -baseline); + } + else if (vert_justify != 't') { int height_pango; double height; pango_layout_get_size (layout, NULL, &height_pango); height = (double) height_pango / PANGO_SCALE; - if (vert_justify == 'b' || vert_justify == 'x') + if (vert_justify == 'b') cairo_rel_move_to (cr, 0, -height); else if (vert_justify == 'c') cairo_rel_move_to (cr, 0, -height / 2.0); -- 2.30.2