From d49e24866f6f989a0e3a00a29281f1f9a1a1d54c Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 31 Aug 2008 23:42:02 +0000 Subject: [PATCH] now the results actually look as they did with the old code only things are FASTER git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1476 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_gfx.c | 6 ++++-- src/rrd_graph.c | 20 +++++++++++++++++--- src/rrd_graph.h | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index be536c5..df3ebcb 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -155,9 +155,11 @@ static PangoLayout *gfx_prep_text( pango_tab_array_free(tab_array); } pfd = pango_layout_get_font_description(layout); - if (pfd && pango_font_description_equal (pfd,font_desc)){ + + if (!pfd || !pango_font_description_equal (pfd,font_desc)){ pango_layout_set_font_description(layout, font_desc); - } + } +// fprintf(stderr,"%s\n",pango_font_description_to_string(pango_layout_get_font_description(layout))); cairo_new_path(cr); cairo_set_source_rgba(cr, color.red, color.green, color.blue, diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 36dbddf..cb93192 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -47,7 +47,7 @@ text_prop_t text_prop[] = { , /* unit */ {8.0, RRD_DEFAULT_FONT,NULL} /* legend */ , - {5.5, RRD_DEFAULT_FONT,NULL} /* watermark */ + {5.5, RRD_DEFAULT_FONT,NULL} /* watermark */ }; xlab_t xlab[] = { @@ -3681,7 +3681,14 @@ rrd_set_font_desc ( static text_prop_t tp_cache[] = { {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}, {-1,"",NULL}}; if (tp_cache[prop].font_desc == NULL){ - tp_cache[prop].font_desc = pango_font_description_new(); + if (prop > 0 && tp_cache[0].font_desc != NULL){ + tp_cache[prop].font_desc = pango_font_description_copy (tp_cache[0].font_desc); + strcpy(tp_cache[prop].font,tp_cache[0].font); + tp_cache[prop].size = tp_cache[0].size; + } + else { + tp_cache[prop].font_desc = pango_font_description_new(); + } im->text_prop[prop].font_desc = pango_font_description_copy (tp_cache[prop].font_desc); } @@ -3700,6 +3707,12 @@ rrd_set_font_desc ( im->text_prop[prop].size = size; tp_cache[prop].size = size; } + if (im->text_prop[prop].size < 0){ + im->text_prop[prop].size = tp_cache[prop].size; + im->text_prop[prop].font_desc = pango_font_description_copy( tp_cache[prop].font_desc ); + strcpy(im->text_prop[prop].font,tp_cache[prop].font); + } + // fprintf(stderr,"%d %s\n",prop,pango_font_description_to_string(im->text_prop[prop].font_desc)); } void rrd_graph_init( @@ -3768,7 +3781,8 @@ void rrd_graph_init( im->cr = cairo_create(im->surface); for (i = 0; i < DIM(text_prop); i++) { - rrd_set_font_desc(im,i, deffont ? deffont : text_prop[i].font,text_prop[i].size); + im->text_prop[i].size = -1; + rrd_set_font_desc(im,i, deffont ? deffont : text_prop[i].font,text_prop[i].size); } im->layout = pango_cairo_create_layout(im->cr); diff --git a/src/rrd_graph.h b/src/rrd_graph.h index fefa982..6276508 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -61,7 +61,8 @@ enum vdef_op_en { , VDEF_LSLINT /* least squares line y_intercept */ , VDEF_LSLCORREL /* least squares line correlation coefficient */ }; -enum text_prop_en { TEXT_PROP_DEFAULT = 0, /* default settings */ +enum text_prop_en { + TEXT_PROP_DEFAULT = 0, /* default settings */ TEXT_PROP_TITLE, /* properties for the title */ TEXT_PROP_AXIS, /* for the numbers next to the axis */ TEXT_PROP_UNIT, /* for the vertical unit description */ -- 2.30.2