*** empty log message ***
[m17n/m17n-test.git] / gdkdraw.c
index e66b710..1da56d9 100644 (file)
--- a/gdkdraw.c
+++ b/gdkdraw.c
@@ -7,7 +7,7 @@
 #include <m17n-gui.h>
 #include <m17n-misc.h>
 
-#define FONT_PT_SIZE 60
+#define FONT_PT_SIZE 40
 
 gint
 delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
@@ -32,10 +32,13 @@ 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;
 
+  gtk_init (&argc, &argv);
+
   if (argc < 2)
     {
       fprintf (stderr, "Usage: gdkdraw LANGUAGE\n");
@@ -58,19 +61,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 +87,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 +177,20 @@ main (int argc, char **argv)
     guchar *pixels, *p;
     int x, y;
     PangoAttrList *attr_list;
-    PangoAttribute *attr_size, *attr_family;
-
-    gtk_init (&argc, &argv);
+    PangoAttribute *attr_size;
 
     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);
@@ -208,7 +214,6 @@ main (int argc, char **argv)
     box = gtk_vbox_new (FALSE, 0);
     text = gtk_image_new_from_pixbuf (pixbuf);
     label = gtk_label_new ((gchar *) title);
-    gtk_label_set_attributes (GTK_LABEL (label), attr_list);
     gtk_box_pack_start (GTK_BOX (box), text, TRUE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);
 
@@ -219,6 +224,7 @@ main (int argc, char **argv)
                         GTK_SIGNAL_FUNC (destroy), NULL);
     gtk_widget_show (text);
     gtk_widget_show (label);
+    gtk_label_set_attributes (GTK_LABEL (label), attr_list);
     gtk_widget_show (box);
     gtk_widget_show (window);
     gtk_main ();