--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <pango/pango.h>
+#include <pango/pangocairo.h>
+
+int
+main (int argc, char **argv)
+{
+ FILE *fp;
+ struct stat statbuf;
+ char *buf;
+ size_t nbytes;
+ PangoFontMap *fontmap;
+ PangoContext *context;
+ PangoLayout *layout;
+ int width, height;
+ int count = 1;
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "Usage: viewfile FILENAME [COUNT]\n");
+ exit (1);
+ }
+ if (argc > 2)
+ count = atoi (argv[2]);
+
+ if (stat (argv[1], &statbuf) != 0
+ || ! (fp = fopen (argv[1], "r")))
+ {
+ fprintf (stderr, "Can't open \"%s\"\n", argv[1]);
+ exit (1);
+ }
+ buf = alloca (statbuf.st_size + 1);
+ fread (buf, 1, statbuf.st_size, fp);
+ fclose (fp);
+ buf[statbuf.st_size] = '\0';
+
+ fontmap = pango_cairo_font_map_get_default ();
+ context = pango_cairo_font_map_create_context ((PangoCairoFontMap *) fontmap);
+ layout = pango_layout_new (context);
+ while (count-- > 0)
+ {
+ int w, h;
+
+ pango_layout_set_text (layout, buf, statbuf.st_size);
+ pango_layout_get_pixel_size (layout, &width, &height);
+ pango_layout_set_text (layout, "abc", 3);
+ pango_layout_get_pixel_size (layout, &w, &h);
+ }
+ printf ("%dx%d\n", width, height);
+ exit (0);
+}