Code

now the results actually look as they did with the old code only things are FASTER
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 31 Aug 2008 23:42:02 +0000 (23:42 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Sun, 31 Aug 2008 23:42:02 +0000 (23:42 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1476 a5681a0c-68f1-0310-ab6d-d61299d08faa

src/rrd_gfx.c
src/rrd_graph.c
src/rrd_graph.h

index be536c5183020778822e2d1ac885c748f817c314..df3ebcbd267668021ed9323cb03fc6d612827cb9 100644 (file)
@@ -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,
index 36dbddffe9566564e74da1349abe348b7ddd81a9..cb93192598bc98239306e091b035bd38cc6164ba 100644 (file)
@@ -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);    
index fefa982f3f5171cffbdade54f08d9333a93cfb18..62765086a69c5d7b4605d38a8037c275507071ce 100644 (file)
@@ -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 */