From: oetiker Date: Fri, 10 Jun 2005 18:44:40 +0000 (+0000) Subject: make --font more flexible: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=80622d45cc00bd55f04ee432b6d89c44a38d25c8;p=rrdtool-all.git make --font more flexible: * TITLE:30: just alter the size of the title * DEFAULT:0:/tmp/funfont.ttf alter the font but not the size git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@616 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/doc/rrdgraph.pod b/program/doc/rrdgraph.pod index 121a65ef..c4ee169f 100644 --- a/program/doc/rrdgraph.pod +++ b/program/doc/rrdgraph.pod @@ -266,7 +266,7 @@ A green arrow is made by: C<--color ARROW:00FF00> Zoom the graphics by the given amount. The factor must be E 0 -[B<-n>|B<--font> IB<:>IB<:>I] +[B<-n>|B<--font> IB<:>IB<:>[I]] This lets you customize which font to use for the various text elements on the RRD graphs. C sets the default value for all @@ -275,6 +275,13 @@ for the vertical unit label, C for the graph legend. Use Times for the title: C<--font TITLE:13:/usr/lib/fonts/times.ttf> +If you do not give a font string you can modify just the sice of the default font: +C<--font TITLE:13:>. + +If you specify the size 0 then you can modify just the font without touching +the size. This is especially usefull for altering the default font without +resetting the default fontsizes: C<--font DEFAULT:0:/usr/lib/fonts/times.ttf>. + RRDtool comes with a preset default font. You can set the environment variable C if you want to change this. diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 8b8a962a..ebd91fb0 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -3152,20 +3152,17 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) if(sscanf(optarg, "%10[A-Z]:%lf:%1000s", prop,&size,font) == 3){ - int sindex; + int sindex,propidx; if((sindex=text_prop_conv(prop)) != -1){ - im->text_prop[sindex].size=size; - strcpy(im->text_prop[sindex].font,font); - if (sindex==0) { /* the default */ - im->text_prop[TEXT_PROP_TITLE].size=size; - strcpy(im->text_prop[TEXT_PROP_TITLE].font,font); - im->text_prop[TEXT_PROP_AXIS].size=size; - strcpy(im->text_prop[TEXT_PROP_AXIS].font,font); - im->text_prop[TEXT_PROP_UNIT].size=size; - strcpy(im->text_prop[TEXT_PROP_UNIT].font,font); - im->text_prop[TEXT_PROP_LEGEND].size=size; - strcpy(im->text_prop[TEXT_PROP_LEGEND].font,font); - } + for (propidx=sindex;propidx 0){ + im->text_prop[propidx].size=size; + } + if (strlen(font) > 0){ + strcpy(im->text_prop[propidx].font,font); + } + if (propidx==sindex && sindex != 0) break; + } } else { rrd_set_error("invalid fonttag '%s'",prop); return;