From 51c6bdc41243a5071256479672a4b18de413ecf1 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 18 May 2008 22:11:56 +0000 Subject: [PATCH] * document tabwidth option * fix \t -> tab expansion git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1371 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_gfx.c | 10 ++-------- src/rrd_graph.c | 12 ++++++++---- src/rrd_tool.c | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index 7ba93ca..5e5072d 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -131,6 +131,7 @@ static PangoLayout *gfx_prep_text( long i; long tab_count = strlen(text); long tab_shift = fmod(x, tabwidth); + int border = im->text_prop[TEXT_PROP_LEGEND].size * 2.0; PangoTabArray *tab_array; PangoContext *pango_context; @@ -138,7 +139,7 @@ static PangoLayout *gfx_prep_text( tab_array = pango_tab_array_new(tab_count, (gboolean) (1)); for (i = 1; i <= tab_count; i++) { pango_tab_array_set_tab(tab_array, - i, PANGO_TAB_LEFT, tabwidth * i - tab_shift); + i, PANGO_TAB_LEFT, tabwidth * i - tab_shift+border); } cairo_new_path(cr); cairo_set_source_rgba(cr, color.red, color.green, color.blue, @@ -170,13 +171,6 @@ double gfx_get_text_width( PangoLayout *layout; PangoRectangle log_rect; gfx_color_t color = { 0, 0, 0, 0 }; - char *tab; - - /* turn \\t into tab */ - while ((tab = strstr(text, "\\t"))) { - memmove(tab + 1, tab + 2, strlen(tab + 2)); - tab[0] = (char) 9; - } layout = gfx_prep_text(im, start, color, font, size, tabwidth, text); pango_layout_get_pixel_extents(layout, NULL, &log_rect); pango_tab_array_free(pango_layout_get_tabs(layout)); diff --git a/src/rrd_graph.c b/src/rrd_graph.c index a0e3ddc..eae4c3d 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1620,6 +1620,7 @@ int leg_place( char prt_fctn; /*special printfunctions */ char default_txtalign = TXA_JUSTIFIED; /*default line orientation */ int *legspace; + char *tab; if (!(im->extra_flags & NOLEGEND) & !(im->extra_flags & ONLY_GRAPH)) { if ((legspace = malloc(im->gdes_c * sizeof(int))) == NULL) { @@ -1648,13 +1649,16 @@ int leg_place( im->gdes[i].legend[0] = '\0'; } + /* turn \\t into tab */ + while ((tab = strstr(im->gdes[i].legend, "\\t"))) { + memmove(tab, tab + 1, strlen(tab)); + tab[0] = (char) 9; + } leg_cc = strlen(im->gdes[i].legend); /* is there a controle code ant the end of the legend string ? */ - /* and it is not a tab \\t */ if (leg_cc >= 2 && im->gdes[i].legend[leg_cc - - 2] == '\\' - && im->gdes[i].legend[leg_cc - 1] != 't') { + 2] == '\\' ) { prt_fctn = im->gdes[i].legend[leg_cc - 1]; leg_cc -= 2; im->gdes[i].legend[leg_cc] = '\0'; @@ -1667,7 +1671,7 @@ int leg_place( prt_fctn != 'j' && prt_fctn != 'c' && prt_fctn != 's' && - prt_fctn != 't' && prt_fctn != '\0' && prt_fctn != 'g') { + prt_fctn != '\0' && prt_fctn != 'g') { free(legspace); rrd_set_error ("Unknown control code at the end of '%s\\%c'", diff --git a/src/rrd_tool.c b/src/rrd_tool.c index b594a5f..169631c 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -141,6 +141,7 @@ void PrintUsage( "\t\t[-M|--alt-autoscale-max]\n" "\t\t[-R|--font-render-mode {normal,light,mono}]\n" "\t\t[-B|--font-smoothing-threshold size]\n" + "\t\t[-T|--tabwidth width]\n" "\t\t[-E|--slope-mode]\n" "\t\t[-N|--no-gridfit]\n" "\t\t[-X|--units-exponent value]\n" -- 2.11.0