X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_gfx.c;h=6604352c43dbf4d43fa4cf3538b4ff937000a7e1;hb=9a5fdb3f8db54f97bdab9284bbf15ff0b31a5169;hp=aa7b3ae9fa84ac18849b6f0d757b51c527e063c1;hpb=7bd35b8d099910071a57c66687f6ef79c5df9a5c;p=rrdtool.git diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index aa7b3ae..6604352 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.3rc7 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.3.1 Copyright by Tobi Oetiker, 1997-2008 **************************************************************************** * rrd_gfx.c graphics wrapper for rrdtool **************************************************************************/ @@ -46,10 +46,13 @@ void gfx_dashed_line( double dash_off) { cairo_t *cr = im->cr; - double dashes[] = { dash_on, dash_off }; + double dashes[2]; double x = 0; double y = 0; + dashes[0] = dash_on; + dashes[1] = dash_off; + cairo_save(cr); cairo_new_path(cr); cairo_set_line_width(cr, width); @@ -133,6 +136,8 @@ static PangoLayout *gfx_prep_text( long tab_shift = fmod(x, tabwidth); int border = im->text_prop[TEXT_PROP_LEGEND].size * 2.0; + gchar *utf8_text; + PangoTabArray *tab_array; PangoContext *pango_context; @@ -153,11 +158,23 @@ static PangoLayout *gfx_prep_text( /* pango_cairo_update_context(cr, pango_context); */ pango_layout_set_tabs(layout, tab_array); + pango_tab_array_free(tab_array); font_desc = pango_font_description_from_string(font); pango_font_description_set_size(font_desc, size * PANGO_SCALE); pango_layout_set_font_description(layout, font_desc); + pango_font_description_free(font_desc); + /* pango expects the string to be utf-8 encoded */ + utf8_text = g_locale_to_utf8((const gchar *) text, -1, NULL, NULL, NULL); + + /* In case of an error, i.e. utf8_text == NULL (locale settings messed + * up?), we fall back to a possible "invalid UTF-8 string" warning instead + * of provoking a failed assertion in libpango. */ if (im->with_markup) - pango_layout_set_markup(layout, text, -1); + pango_layout_set_markup(layout, utf8_text ? utf8_text : text, -1); + else + pango_layout_set_text(layout, utf8_text ? utf8_text : text, -1); + + g_free(utf8_text); return layout; } @@ -175,7 +192,6 @@ double gfx_get_text_width( gfx_color_t color = { 0, 0, 0, 0 }; 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)); g_object_unref(layout); return log_rect.width; } @@ -236,7 +252,6 @@ void gfx_text( pango_cairo_update_layout(cr, layout); cairo_move_to(cr, sx, sy); pango_cairo_show_layout(cr, layout); - pango_tab_array_free(pango_layout_get_tabs(layout)); g_object_unref(layout); cairo_restore(cr);