Code

Added debian/patches/bts493553-pango-utf-8. debian/1.3.1-3
authorSebastian Harl <sh@tokkee.org>
Mon, 4 Aug 2008 13:59:33 +0000 (15:59 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 4 Aug 2008 13:59:33 +0000 (15:59 +0200)
This patch tries to make sure an UTF-8 string is passed to
pango_layout_set_{text,markup}() as required by libpango.

Closes: #493553
debian/changelog
debian/patches/bts493553-pango-utf-8 [new file with mode: 0644]
debian/patches/series

index 4be7f7b0cbeb66dccd975e0d1da7c65968c2dd70..702068c65a6d4d390da93583463de05fdda02f59 100644 (file)
@@ -1,8 +1,12 @@
 rrdtool (1.3.1-3) unstable; urgency=low
 
   * Added "libxml2-dev" to librrd-dev's dependencies (Closes: #493342).
+  * debian/patches:
+    - Added bts493553-pango-utf-8 to try to make sure an UTF-8 string is
+      passed to pango_layout_set_{text,markup}() as required by libpango
+      (Closes: #493553).
 
- -- Sebastian Harl <sh@tokkee.org>  Sat,  2 Aug 2008 11:11:34 +0200
+ -- Sebastian Harl <sh@tokkee.org>  Mon, 04 Aug 2008 15:57:26 +0200
 
 rrdtool (1.3.1-2) unstable; urgency=low
 
diff --git a/debian/patches/bts493553-pango-utf-8 b/debian/patches/bts493553-pango-utf-8
new file mode 100644 (file)
index 0000000..f016688
--- /dev/null
@@ -0,0 +1,34 @@
+diff a/src/rrd_gfx.c b/src/rrd_gfx.c
+--- a/src/rrd_gfx.c
++++ b/src/rrd_gfx.c
+@@ -133,6 +133,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;
+@@ -156,10 +158,19 @@ static PangoLayout *gfx_prep_text(
+     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 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, text, -1);
++        pango_layout_set_text(layout, utf8_text ? utf8_text : text, -1);
++
++    g_free(utf8_text);
+     return layout;
+ }
index 69cecaaf69d7d1e3dd0691a382f19e6017caaff2..cd2055ff4d695918576215725094f431f4bcfec6 100644 (file)
@@ -1,4 +1,5 @@
 bts428778-floating-point-exception
+bts493553-pango-utf-8
 setup.py-module-name
 no-rpath-for-ruby
 no-rpath-for-perl