output: Fix vertical alignment of text to a baseline in chart output.
authorBen Pfaff <blp@gnu.org>
Thu, 30 Jul 2009 04:26:55 +0000 (21:26 -0700)
committerBen Pfaff <blp@gnu.org>
Thu, 30 Jul 2009 04:26:55 +0000 (21:26 -0700)
This makes labels on pie charts look better, for example.

src/output/charts/plot-chart.c

index 8d499866073e8be7a69fecd1f3195433cbadc9a3..04c10c4d9122e199e8fab4ac63cf02da1b3e1257 100644 (file)
@@ -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);