Index: examples/pangoft2topgm.c
===================================================================
RCS file: /cvs/gnome/pango/examples/pangoft2topgm.c,v
retrieving revision 1.15
diff -u -p -r1.15 pangoft2topgm.c
--- examples/pangoft2topgm.c	9 Jan 2005 00:12:39 -0000	1.15
+++ examples/pangoft2topgm.c	15 Mar 2005 03:08:30 -0000
@@ -49,35 +49,42 @@ main(int argc, char *argv[])
   PangoFontMap *fontmap;
   GError *error = NULL;
   gboolean do_convert = FALSE;
+  gboolean gen_output = TRUE;
 
   g_type_init();
 
   parse_options (argc, argv);
 
-  if (opt_output)
-    {
-      if (!(g_str_has_suffix (opt_output, ".pgm") ||
-	    g_str_has_suffix (opt_output, ".PGM")))
-	do_convert = TRUE;
-    }
+  if (opt_output && !*opt_output)
+    gen_output = FALSE;
 
-  if (opt_output && !do_convert)
+  if (gen_output)
     {
-      outfile = fopen (opt_output, "wb");
+      if (opt_output)
+	{
+	  if (!(g_str_has_suffix (opt_output, ".pgm") ||
+		g_str_has_suffix (opt_output, ".PGM")))
+	    do_convert = TRUE;
+	}
 
-      if (!outfile)
-	fail ("Cannot open output file %s: %s\n",
-	      opt_output, g_strerror (errno));
-    }
-  else				/* --display */
-    {
-      /* This may need to be G_OS_UNIX guarded for fdopen */
-      int fd = g_file_open_tmp ("pangoft2pgmXXXXXX", &tmpfile_name, &error);
-      if (fd == 1)
-	fail ("Cannot open temporary file: %s\n", error->message);
-      outfile = fdopen (fd, "wb");
-      if (!outfile)
-	fail ("Cannot open temporary file: %s\n", g_strerror (errno));
+      if (opt_output && !do_convert)
+	{
+	  outfile = fopen (opt_output, "wb");
+
+	  if (!outfile)
+	    fail ("Cannot open output file %s: %s\n",
+		  opt_output, g_strerror (errno));
+	}
+      else				/* --display */
+	{
+	  /* This may need to be G_OS_UNIX guarded for fdopen */
+	  int fd = g_file_open_tmp ("pangoft2pgmXXXXXX", &tmpfile_name, &error);
+	  if (fd == 1)
+	    fail ("Cannot open temporary file: %s\n", error->message);
+	  outfile = fdopen (fd, "wb");
+	  if (!outfile)
+	    fail ("Cannot open temporary file: %s\n", g_strerror (errno));
+	}
     }
 
   fontmap = pango_ft2_font_map_new ();
@@ -86,12 +93,12 @@ main(int argc, char *argv[])
   pango_ft2_font_map_set_default_substitute (PANGO_FT2_FONT_MAP (fontmap), fc_substitute_func, NULL, NULL);
   context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
 
-  /* Write contents as pgm file */
   {
       FT_Bitmap bitmap;
       guchar *buf;
       int row;
       int width, height;
+      int run;
 
       do_output (context, NULL, NULL, NULL, &width, &height);
       
@@ -103,74 +110,78 @@ main(int argc, char *argv[])
       bitmap.pixel_mode = ft_pixel_mode_grays;
       memset (buf, 0x00, bitmap.pitch * bitmap.rows);
 
-      do_output (context, ft2_render, NULL, &bitmap, &width, &height);
+      for (run = 0; run < opt_runs; run++)
+	do_output (context, ft2_render, NULL, &bitmap, &width, &height);
 
-      /* Invert bitmap to get black text on white background */
-      {
-	int pix_idx;
-	for (pix_idx=0; pix_idx<bitmap.pitch * bitmap.rows; pix_idx++)
+      if (gen_output)
+        {
+	  /* Invert bitmap to get black text on white background */
 	  {
-	    buf[pix_idx] = 255-buf[pix_idx];
+	    int pix_idx;
+	    for (pix_idx=0; pix_idx<bitmap.pitch * bitmap.rows; pix_idx++)
+	      {
+		buf[pix_idx] = 255-buf[pix_idx];
+	      }
 	  }
-      }
-      
-      /* Write it as pgm to output */
-      fprintf(outfile,
-	      "P5\n"
-	      "%d %d\n"
-	      "255\n", bitmap.width, bitmap.rows);
-      for (row = 0; row < bitmap.rows; row++)
-	fwrite(bitmap.buffer + row * bitmap.pitch,
-	       1, bitmap.width,
-	       outfile);
-      g_free (buf);
-      if (fclose(outfile) == EOF)
-	fail ("Error writing output file: %s\n", g_strerror (errno));
-
-      /* Convert to a different format, if necessary */
-      if (do_convert)
-	{
-	  int exit_status;
 	  
-	  gchar *command = g_strdup_printf ("convert %s %s",
-					    tmpfile_name,
-					    opt_output);
-	  if (!g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error))
-	    fail ("When running ImageMagick 'convert' command: %s\n",
-		  error->message);
+	  /* Write it as pgm to output */
+	  fprintf(outfile,
+		  "P5\n"
+		  "%d %d\n"
+		  "255\n", bitmap.width, bitmap.rows);
+	  for (row = 0; row < bitmap.rows; row++)
+	    fwrite(bitmap.buffer + row * bitmap.pitch,
+		   1, bitmap.width,
+		   outfile);
+	  g_free (buf);
+	  if (fclose(outfile) == EOF)
+	    fail ("Error writing output file: %s\n", g_strerror (errno));
 
-	  if (tmpfile_name)
+	  /* Convert to a different format, if necessary */
+	  if (do_convert)
 	    {
-	      remove (tmpfile_name);
-	      tmpfile_name = NULL;
+	      int exit_status;
+	      
+	      gchar *command = g_strdup_printf ("convert %s %s",
+						tmpfile_name,
+						opt_output);
+	      if (!g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error))
+		fail ("When running ImageMagick 'convert' command: %s\n",
+		      error->message);
+
+	      if (tmpfile_name)
+		{
+		  remove (tmpfile_name);
+		  tmpfile_name = NULL;
+		}
+	      
+	      if (exit_status)
+		exit (1);
 	    }
-	  
-	  if (exit_status)
-	    exit (1);
-	}
 
-      if (opt_display)
-	{
-	  int exit_status;
-	  gchar *title = get_options_string ();
-	  gchar *title_quoted = g_shell_quote (title);
-	  
-	  gchar *command = g_strdup_printf ("display -title %s %s",
-					    title_quoted,
-					    opt_output ? opt_output: tmpfile_name);
-	  if (!g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error))
-	    fail ("When running ImageMagick 'display' command: %s\n",
-		  error->message);
-
-	  g_free (command);
-	  g_free (title);
-	  g_free (title_quoted);
-	  
-	  if (tmpfile_name)
-	    remove (tmpfile_name);
-	  
-	  if (exit_status)
-	    exit (1);
+	  if (opt_display)
+	    {
+	      int exit_status;
+	      gchar *title = get_options_string ();
+	      gchar *title_quoted = g_shell_quote (title);
+	      
+	      gchar *command = g_strdup_printf ("display -title %s %s",
+						title_quoted,
+						opt_output ? opt_output: tmpfile_name);
+	      if (!g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error))
+		fail ("When running ImageMagick 'display' command: %s\n",
+		      error->message);
+
+	      g_free (command);
+	      g_free (title);
+	      g_free (title_quoted);
+	      
+	      if (tmpfile_name)
+		remove (tmpfile_name);
+	      
+	      if (exit_status)
+		exit (1);
+	    }
 	}
     }
 
Index: examples/renderdemo.c
===================================================================
RCS file: /cvs/gnome/pango/examples/renderdemo.c,v
retrieving revision 1.18
diff -u -p -r1.18 renderdemo.c
--- examples/renderdemo.c	9 Jan 2005 00:12:39 -0000	1.18
+++ examples/renderdemo.c	15 Mar 2005 03:08:31 -0000
@@ -54,6 +54,7 @@ char *opt_text = NULL;
 gboolean opt_waterfall = FALSE;
 int opt_width = -1;
 int opt_indent = 0;
+int opt_runs = 1;
 PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE;
 HintMode opt_hinting = HINT_DEFAULT;
 
@@ -411,6 +412,8 @@ parse_options (int argc, char *argv[])
       ARG_INT,      &opt_width },
     { "indent",     "Width in points to indent paragraphs",
       ARG_INT,      &opt_indent },
+    { "runs",       "Render text this many times",
+      ARG_INT,      &opt_runs },
     { NULL }
   };
 
Index: examples/renderdemo.h
===================================================================
RCS file: /cvs/gnome/pango/examples/renderdemo.h,v
retrieving revision 1.4
diff -u -p -r1.4 renderdemo.h
--- examples/renderdemo.h	9 Jan 2005 00:12:39 -0000	1.4
+++ examples/renderdemo.h	15 Mar 2005 03:08:31 -0000
@@ -67,5 +67,6 @@ extern char *opt_text;
 extern gboolean opt_waterfall;
 extern int opt_width;
 extern int opt_indent;
+extern int opt_runs;
 extern PangoEllipsizeMode opt_ellipsize;
 extern HintMode opt_hinting;
