/*
  Test case for Pango bug concerning overlapping characters.

  Compile with:
   gcc `pkg-config --cflags --libs gtk+-2.0` test-pango.c

  The 'T' and 'e' characters overlap here.
*/

#include <gtk/gtk.h>


gboolean
on_expose_event (GtkWidget *window, GdkEvent *event, gpointer data)
{
  PangoLayout *layout;
  PangoContext *context;
  PangoFontDescription *font_desc;
  cairo_font_options_t *font_options;
  cairo_t *cr;

  cr = gdk_cairo_create (window->window);

  /* If we scale here it doesn't work. */
#if 1
  cairo_scale (cr, 3, 3);
#endif

  layout = pango_cairo_create_layout (cr);

  /* If we scale it after creating the layout it works OK. */
#if 0
  cairo_scale (cr, 3, 3);
#endif

  /* This doesn't seem to help. It actually breaks the second case above. */
#if 0
  pango_cairo_update_layout (cr, layout);
#endif

  pango_layout_set_text (layout, "Text", -1);

  font_desc = pango_font_description_from_string ("Bitstream Vera Sans 12");
  pango_layout_set_font_description (layout, font_desc);
  pango_font_description_free (font_desc);

  cairo_move_to (cr, 10, 10);
  pango_cairo_show_layout (cr, layout);

  g_object_unref (layout);
  cairo_destroy (cr);

  return TRUE;
}


int
main (int argc, char *argv[])
{
  GtkWidget *window, *darea;

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);

  g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event),
		    NULL);

  gtk_widget_show (window);

  gtk_main ();
  return 0;
}

