X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_gfx.c;h=2cdf20cced85184bb8aee394694b9aed3be5d9cf;hb=ec2afe5e94d9fcd72bb58e572f0251c7557325f7;hp=c56211dae3c2f3e6eccccff36858d3f3db3963bb;hpb=db0f95ebbf69868993aa6ec59eb45e13aabbef06;p=rrdtool.git diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index c56211d..2cdf20c 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -1,16 +1,21 @@ /**************************************************************************** - * RRDtool 1.2.12 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007 **************************************************************************** * rrd_gfx.c graphics wrapper for rrdtool **************************************************************************/ /* #define DEBUG */ -#ifdef DEBUG -# define DPRINTF(...) fprintf(stderr, __VA_ARGS__); -#else -# define DPRINTF(...) -#endif +/* stupid MSVC doesnt support variadic macros = no debug for now! */ +#ifdef _MSC_VER +# define RRDPRINTF() +#else +# ifdef DEBUG +# define RRDPRINTF(...) fprintf(stderr, __VA_ARGS__); +# else +# define RRDPRINTF(...) +# endif /* DEBUG */ +#endif /* _MSC_VER */ #include "rrd_tool.h" #include #include @@ -461,12 +466,12 @@ gfx_string gfx_string_create(gfx_canvas_t *canvas, FT_Face face,const char *text canvas->aa_type == AA_LIGHT ? FT_LOAD_TARGET_LIGHT : FT_LOAD_TARGET_MONO : FT_LOAD_TARGET_MONO); if (error) { - DPRINTF("couldn't load glyph: %c\n", letter) + RRDPRINTF("couldn't load glyph: %c\n", letter) continue; } error = FT_Get_Glyph (slot, &glyph->image); if (error) { - DPRINTF("couldn't get glyph %c from slot %d\n", letter, (int)slot) + RRDPRINTF("couldn't get glyph %c from slot %d\n", letter, (int)slot) continue; } /* if we are in tabbing mode, we replace the tab with a space and shift the position @@ -488,7 +493,7 @@ gfx_string gfx_string_create(gfx_canvas_t *canvas, FT_Face face,const char *text FT_Vector_Transform (&vec, &string->transform); error = FT_Glyph_Transform (glyph->image, &string->transform, &vec); if (error) { - DPRINTF("couldn't transform glyph id %d\n", letter) + RRDPRINTF("couldn't transform glyph id %d\n", letter) continue; } @@ -498,7 +503,7 @@ gfx_string gfx_string_create(gfx_canvas_t *canvas, FT_Face face,const char *text canvas->aa_type == AA_LIGHT ? FT_RENDER_MODE_LIGHT : FT_RENDER_MODE_MONO : FT_RENDER_MODE_MONO, 0, 1); if (error) { - DPRINTF("couldn't convert glyph id %d to bitmap\n", letter) + RRDPRINTF("couldn't convert glyph id %d to bitmap\n", letter) continue; } @@ -615,11 +620,16 @@ int gfx_render_png (gfx_canvas_t *canvas, (long)(node->size*64), (long)(100*canvas->zoom), (long)(100*canvas->zoom)); - if ( error ) break; + if ( error ) { + FT_Done_Face(face); + break; + } pen_x = node->x * canvas->zoom; pen_y = node->y * canvas->zoom; string = gfx_string_create (canvas, face, node->text, node->angle, node->tabwidth, node->size); + FT_Done_Face(face); + switch(node->halign){ case GFX_H_RIGHT: vec.x = -string->bbox.xMax; break; @@ -653,12 +663,12 @@ int gfx_render_png (gfx_canvas_t *canvas, /* long buf_x,comp_n; */ /* make copy to transform */ if (! glyph->image) { - DPRINTF("no image\n") + RRDPRINTF("no image\n") continue; } error = FT_Glyph_Copy (glyph->image, &image); if (error) { - DPRINTF("couldn't copy image\n") + RRDPRINTF("couldn't copy image\n") continue; } @@ -1062,7 +1072,9 @@ static void svg_write_text(FILE *fp, const char *text) text_count = mbstowcs(cstr, "Enc-Err", 6); p = cstr; #else - const unsigned char *p = text, ch; + unsigned char *p = text; + unsigned char *cstr; + char ch; if (!p) return; #endif @@ -1071,7 +1083,7 @@ static void svg_write_text(FILE *fp, const char *text) ch = afm_fix_osx_charset(ch); /* unsafe macro */ switch (ch) { case 0: -#ifdef HAVE_MBSTOWCS +#ifdef HAVE_MBSTOWCS free(cstr); #endif return; @@ -1081,7 +1093,7 @@ static void svg_write_text(FILE *fp, const char *text) case '"': fputs(""", fp); break; default: if (ch == 32) { -#ifdef HAVE_MBSTOWCS +#ifdef HAVE_MBSTOWCS if (p <= cstr + 1 || !*p || *p == 32) fputs(" ", fp); /* non-breaking space in unicode */ else @@ -1747,7 +1759,8 @@ static void eps_write_text(eps_state *state, gfx_node_t *node) text_count = mbstowcs(cstr, "Enc-Err", 6); p = cstr; #else - const unsigned char *p = node->text, ch; + const unsigned char *p = node->text; + unsigned char ch; if (!p) return; #endif @@ -2034,9 +2047,9 @@ static void pdf_put_string_contents_wide(pdf_buffer *buf, const afm_char *text) default: if (ch > 255) { pdf_put_char(buf, '?'); - } else if (ch >= 126 || ch < 32) { + } else if (ch > 125 || ch < 32) { pdf_put_char(buf, ch); - } else if (ch >= 0 && ch <= 255) { + } else { char tmp[10]; snprintf(tmp, sizeof(tmp), "\\%03o", (int)ch); pdf_puts(buf, tmp);