From c9aa2a83f27a47bbb33969e6115e99fe049001b4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 29 Jul 2009 21:33:19 -0700 Subject: [PATCH] output: Draw titles on charts in a larger font than other labels. --- src/output/chart-provider.h | 2 +- src/output/chart.c | 2 +- src/output/charts/box-whisker.c | 2 +- src/output/charts/piechart.c | 6 ++++-- src/output/charts/plot-chart.c | 15 +++++++-------- src/output/charts/plot-chart.h | 2 +- src/output/charts/plot-hist.c | 6 +++--- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/output/chart-provider.h b/src/output/chart-provider.h index fa63286154..6065036d0f 100644 --- a/src/output/chart-provider.h +++ b/src/output/chart-provider.h @@ -47,7 +47,7 @@ struct chart_geometry int legend_right ; /* Default font size for the plot. */ - int font_size; + double font_size; struct chart_colour fill_colour; diff --git a/src/output/chart.c b/src/output/chart.c index ab2e57c192..e1832e20bb 100644 --- a/src/output/chart.c +++ b/src/output/chart.c @@ -62,7 +62,7 @@ chart_geometry_init (cairo_t *cr, struct chart_geometry *geom, geom->title_bottom = 0.920 * length; geom->legend_left = 0.810 * width; geom->legend_right = width; - geom->font_size = 10; + geom->font_size = 15.0; geom->fill_colour.red = 255; geom->fill_colour.green = 0; diff --git a/src/output/charts/box-whisker.c b/src/output/charts/box-whisker.c index ea1b462451..ba3df29020 100644 --- a/src/output/charts/box-whisker.c +++ b/src/output/charts/box-whisker.c @@ -96,7 +96,7 @@ draw_case (cairo_t *cr, const struct chart_geometry *geom, double centreline, 20); cairo_move_to (cr, centreline + 10, y); - chart_label (cr, 'l', 'c', ds_cstr (&outlier->label)); + chart_label (cr, 'l', 'c', geom->font_size, ds_cstr (&outlier->label)); } static void diff --git a/src/output/charts/piechart.c b/src/output/charts/piechart.c index 91f920881c..c6e6b24f65 100644 --- a/src/output/charts/piechart.c +++ b/src/output/charts/piechart.c @@ -131,7 +131,8 @@ piechart_draw (const struct chart *chart, cairo_t *cr, cairo_line_to (cr, left_label, label_y); cairo_stroke (cr); cairo_move_to (cr, left_label, label_y + 5); - chart_label (cr, 'l', 'x', ds_cstr (&pie->slices[i].label)); + chart_label (cr, 'l', 'x', geom->font_size, + ds_cstr (&pie->slices[i].label)); } else { @@ -139,7 +140,8 @@ piechart_draw (const struct chart *chart, cairo_t *cr, cairo_line_to (cr, right_label, label_y); cairo_stroke (cr); cairo_move_to (cr, right_label, label_y + 5); - chart_label (cr, 'r', 'x', ds_cstr (&pie->slices[i].label)); + chart_label (cr, 'r', 'x', geom->font_size, + ds_cstr (&pie->slices[i].label)); } angle += segment_angle; diff --git a/src/output/charts/plot-chart.c b/src/output/charts/plot-chart.c index 04c10c4d91..98e4c866e8 100644 --- a/src/output/charts/plot-chart.c +++ b/src/output/charts/plot-chart.c @@ -86,7 +86,7 @@ chart_draw_marker (cairo_t *cr, double x, double y, enum marker_type marker, } void -chart_label (cairo_t *cr, int horz_justify, int vert_justify, +chart_label (cairo_t *cr, int horz_justify, int vert_justify, double font_size, const char *string) { PangoFontDescription *desc; @@ -99,7 +99,7 @@ chart_label (cairo_t *cr, int horz_justify, int vert_justify, cairo_new_path (cr); return; } - pango_font_description_set_absolute_size (desc, 15 * PANGO_SCALE); + pango_font_description_set_absolute_size (desc, font_size * PANGO_SCALE); cairo_save (cr); cairo_get_current_point (cr, &x, &y); @@ -190,12 +190,12 @@ draw_tick (cairo_t *cr, const struct chart_geometry *geom, va_start (ap, label); s = xvasprintf (label, ap); if (orientation == TICK_ABSCISSA) - chart_label (cr, 'c', 't', s); + chart_label (cr, 'c', 't', geom->font_size, s); else if (orientation == TICK_ORDINATE) { if (fabs (position) < DBL_EPSILON) cairo_rel_move_to (cr, 0, 10); - chart_label (cr, 'r', 'c', s); + chart_label (cr, 'r', 'c', geom->font_size, s); } free (s); va_end (ap); @@ -212,12 +212,11 @@ chart_write_title (cairo_t *cr, const struct chart_geometry *geom, char *s; cairo_save (cr); - // pl_ffontsize_r (cr, geom->font_size * 1.5); /* XXX */ cairo_move_to (cr, geom->data_left, geom->title_bottom); va_start(ap, title); s = xvasprintf (title, ap); - chart_label (cr, 'l', 'x', s); + chart_label (cr, 'l', 'x', geom->font_size * 1.5, s); free (s); va_end (ap); @@ -274,7 +273,7 @@ chart_write_xlabel (cairo_t *cr, const struct chart_geometry *geom, const char *label) { cairo_move_to (cr, geom->data_left, geom->abscissa_top); - chart_label (cr, 'l', 't', label); + chart_label (cr, 'l', 't', geom->font_size, label); } /* Write the ordinate label */ @@ -286,6 +285,6 @@ chart_write_ylabel (cairo_t *cr, const struct chart_geometry *geom, cairo_translate (cr, -geom->data_bottom, -geom->ordinate_right); cairo_move_to (cr, 0, 0); cairo_rotate (cr, M_PI / 2.0); - chart_label (cr, 'l', 'x', label); + chart_label (cr, 'l', 'x', geom->font_size, label); cairo_restore (cr); } diff --git a/src/output/charts/plot-chart.h b/src/output/charts/plot-chart.h index 1a44212ce1..03788f0075 100644 --- a/src/output/charts/plot-chart.h +++ b/src/output/charts/plot-chart.h @@ -59,7 +59,7 @@ void chart_draw_marker (cairo_t *, double x, double y, enum marker_type, double size); void chart_label (cairo_t *, int horz_justify, int vert_justify, - const char *); + double font_size, const char *); /* Draw a tick mark at position If label is non zero, then print it at the tick mark diff --git a/src/output/charts/plot-hist.c b/src/output/charts/plot-hist.c index b7586a18f1..34c98aa2ba 100644 --- a/src/output/charts/plot-hist.c +++ b/src/output/charts/plot-hist.c @@ -50,7 +50,7 @@ histogram_write_legend (cairo_t *cr, const struct chart_geometry *geom, { char *buf = xasprintf ("N = %.2f", n); cairo_move_to (cr, geom->legend_left, y); - chart_label (cr, 'l', 'b', buf); + chart_label (cr, 'l', 'b', geom->font_size, buf); y += geom->font_size * 1.5; free (buf); } @@ -59,7 +59,7 @@ histogram_write_legend (cairo_t *cr, const struct chart_geometry *geom, { char *buf = xasprintf ("Mean = %.1f", mean); cairo_move_to (cr,geom->legend_left, y); - chart_label (cr, 'l', 'b', buf); + chart_label (cr, 'l', 'b', geom->font_size, buf); y += geom->font_size * 1.5; free (buf); } @@ -68,7 +68,7 @@ histogram_write_legend (cairo_t *cr, const struct chart_geometry *geom, { char *buf = xasprintf ("Std. Dev = %.2f", stddev); cairo_move_to (cr, geom->legend_left, y); - chart_label (cr, 'l', 'b', buf); + chart_label (cr, 'l', 'b', geom->font_size, buf); free (buf); } -- 2.30.2