--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <m17n-gui.h>
+
+gint
+delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ return FALSE;
+}
+
+void
+destroy (GtkWidget *widget, gpointer data)
+{
+ gtk_main_quit ();
+}
+
+int
+main (int argc, char **argv)
+{
+ MSymbol lang;
+ MText *mt;
+ GdkPixmap *gdk_pixmap;
+ GtkWidget *window, *box, *text, *label;
+
+ char title[256];
+ int len;
+
+ gtk_init (&argc, &argv);
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "Usage: gtk-m17n LANGUAGE\n");
+ exit (1);
+ }
+
+ M17N_INIT ();
+ lang = msymbol (argv[1]);
+ mt = mlanguage_text (lang);
+ if (! mt)
+ {
+ fprintf (stderr, "No native name for the language \"%s\".\n", argv[1]);
+ exit (1);
+ }
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ box = gtk_vbox_new (FALSE, 0);
+ text = gtk_drawing_area_new ();
+ label = gtk_label_new (title);
+ gtk_box_pack_start (GTK_BOX (box), text, TRUE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), box);
+ gtk_signal_connect (GTK_OBJECT (window), "delete_event",
+ GTK_SIGNAL_FUNC (delete_event), NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (destroy), NULL);
+
+ /* Draw on TEXT widget by m17n-lib. */
+ {
+ Display *display;
+ Pixmap Pixmap;
+ MFrame *frame;
+ MPlist *param = mplist ();
+ MFace *face = mface ();
+ MFontset *fontset = mfontset ("generic");
+ MDrawMetric metric;
+
+ gdk_pixmap = gdk_pixmap_new (window->window,
+
+ mface_put_prop (face, Msize, (void *) -600);
+ mface_put_prop (face, Mfontset, fontset);
+ if (argc > 2)
+ mface_put_prop (face, Mfamily, msymbol (argv[2]));
+ mplist_add (param, Mdevice,
+ mplist_add (param, Mface, face);
+ frame = mframe (param);
+ m17n_object_unref (face);
+ m17n_object_unref (param);
+
+ if (! frame)
+ {
+ fprintf (stderr, "Frame creation failed. Perhaps no GD library.\n");
+ exit (1);
+ }
+ }
+
+ {
+ MDrawControl control;
+
+ memset (&control, 0, sizeof (control));
+ control.anti_alias = 1;
+ mdraw_text_extents (frame, mt, 0, mtext_len (mt), &control,
+ &metric, NULL, NULL);
+
+ image = gdImageCreateTrueColor (metric.width, metric.height);
+ bg_color = gdImageColorAllocate (image, 255, 255, 255);
+ gdImageFilledRectangle (image, 0, 0, metric.width - 1, metric.height - 1,
+ bg_color);
+
+ mdraw_text_with_control (frame, (MDrawWindow) image,
+ - metric.x, - metric.y,
+ mt, 0, mtext_len (mt), &control);
+ }
+
+ m17n_object_unref (frame);
+
+
+
+
+ gtk_label_set_attributes (GTK_LABEL (label), attr_list);
+
+ len = mconv_encode_buffer (msymbol ("utf-8"), mt,
+ (unsigned char *) title, 256);
+ title[len] = '\0';
+
+ M17N_FINI ();
+
+ {
+ GdkPixbuf *pixbuf;
+ GtkWidget *window, *box, *text, *label;
+ int n_channels, rowstride;
+ guchar *pixels, *p;
+ int x, y;
+ PangoAttrList *attr_list = pango_attr_list_new ();
+ PangoAttribute *attr = pango_attr_size_new (60 * PANGO_SCALE);
+
+ pango_attr_list_insert (attr_list, attr);
+
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 0, 8,
+ metric.width, metric.height);
+ n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ pixels = gdk_pixbuf_get_pixels (pixbuf);
+
+ for (y = 0; y < metric.height; y++)
+ for (x = 0; x < metric.width; x++)
+ {
+ int cid = gdImageGetPixel (image, x, y);
+ p = pixels + y * rowstride + x * n_channels;
+
+ p[0] = gdImageRed (image, cid);
+ p[1] = gdImageGreen (image, cid);
+ p[2] = gdImageBlue (image, cid);
+ }
+ gdImageDestroy (image);
+
+ gtk_widget_show (text);
+ gtk_widget_show (label);
+ gtk_widget_show (box);
+ gtk_widget_show (window);
+ gtk_main ();
+ }
+ exit (0);
+}