*** empty log message ***
[m17n/m17n-test.git] / gdkdraw.c
index e66b710..e1408bc 100644 (file)
--- a/gdkdraw.c
+++ b/gdkdraw.c
@@ -32,7 +32,8 @@ main (int argc, char **argv)
   gdImagePtr image;
   int bg_color;
   unsigned char *title;
-  int allocated, len;
+  int title_len;
+  int allocated;
   MSymbol utf8;
   char *family_names = NULL;
 
@@ -58,19 +59,19 @@ main (int argc, char **argv)
   utf8 = msymbol ("utf-8");
   allocated = nchars * 4;      /* Usually this is enough.  */
   title = malloc (allocated);
-  len = mconv_encode_buffer (utf8, mt, title, allocated);
-  while (len < 0 && merror_code == MCONVERSION_RESULT_INSUFFICIENT_DST)
+  title_len = mconv_encode_buffer (utf8, mt, title, allocated);
+  while (title_len < 0 && merror_code == MCONVERSION_RESULT_INSUFFICIENT_DST)
     {
       allocated += allocated;
       title = realloc (title, allocated);
-      len = mconv_encode_buffer (utf8, mt, title, allocated);
+      title_len = mconv_encode_buffer (utf8, mt, title, allocated);
     }
-  if (len < 0)
+  if (title_len < 0)
     {
       fprintf (stderr, "Encoding of native language name failed.");
       exit (1);
     }
-  title[len] = '\0';
+  title[title_len] = '\0';
 
   {
     MPlist *param = mplist ();
@@ -84,6 +85,7 @@ main (int argc, char **argv)
     mplist_add (param, Mdevice, msymbol ("gd"));
     mplist_add (param, Mface, face);
     frame = mframe (param);
+    m17n_object_unref (fontset);
     m17n_object_unref (face);
     m17n_object_unref (param);
 
@@ -173,18 +175,22 @@ main (int argc, char **argv)
     guchar *pixels, *p;
     int x, y;
     PangoAttrList *attr_list;
-    PangoAttribute *attr_size, *attr_family;
+    PangoAttribute *attr_size;
 
     gtk_init (&argc, &argv);
 
     attr_list = pango_attr_list_new ();
     attr_size = pango_attr_size_new (FONT_PT_SIZE * PANGO_SCALE);
-    attr_family = family_names ? pango_attr_family_new (family_names) : NULL;
-#if 0
-    if (attr_family)
-      pango_attr_list_change (attr_list, attr_family);
-#endif
-    pango_attr_list_change (attr_list, attr_size);
+    attr_size->start_index = 0, attr_size->end_index = title_len;
+    pango_attr_list_insert (attr_list, attr_size);
+    if (family_names)
+      {
+       PangoAttribute *attr_family;
+
+       attr_family = pango_attr_family_new (family_names);
+       attr_family->start_index = 0, attr_family->end_index = title_len;
+       pango_attr_list_insert (attr_list, attr_family);
+      }
 
     pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0, 8,
                             metric.width, metric.height);