Code

Added upstream patch bts499349-memleaks.
[pkg-rrdtool.git] / debian / patches / bts493553-pango-utf-8
1 diff a/src/rrd_gfx.c b/src/rrd_gfx.c
2 --- a/src/rrd_gfx.c
3 +++ b/src/rrd_gfx.c
4 @@ -133,6 +133,8 @@ static PangoLayout *gfx_prep_text(
5      long      tab_shift = fmod(x, tabwidth);
6      int       border = im->text_prop[TEXT_PROP_LEGEND].size * 2.0;
7  
8 +    gchar *utf8_text;
9 +
10      PangoTabArray *tab_array;
11      PangoContext *pango_context;
12  
13 @@ -156,10 +158,19 @@ static PangoLayout *gfx_prep_text(
14      font_desc = pango_font_description_from_string(font);
15      pango_font_description_set_size(font_desc, size * PANGO_SCALE);
16      pango_layout_set_font_description(layout, font_desc);
17 +
18 +    /* pango expects the string to be utf-8 encoded */
19 +    utf8_text = g_locale_to_utf8((const gchar *)text, -1, NULL, NULL, NULL);
20 +
21 +    /* In case of an error, i.e. utf8_text == NULL (locale settings messed
22 +     * up?), we fall back to a possible "invalid UTF-8 string" warning instead
23 +     * of provoking a failed assertion in libpango. */
24      if (im->with_markup)
25 -        pango_layout_set_markup(layout, text, -1);
26 +        pango_layout_set_markup(layout, utf8_text ? utf8_text : text, -1);
27      else
28 -        pango_layout_set_text(layout, text, -1);
29 +        pango_layout_set_text(layout, utf8_text ? utf8_text : text, -1);
30 +
31 +    g_free(utf8_text);
32      return layout;
33  }
34