now the results actually look as they did with the old code only things are FASTER
[rrdtool.git] / src / rrd_graph.c
index 36dbddf..cb93192 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);