
#include <gtk/gtk.h>
#include <cairo.h>
#include <pango/pango.h>



static void
demo_draw (cairo_t *cr)
{
	gdouble               scale;
	PangoLayout          *layout;
        PangoFontDescription *desc;
	gchar                *text;

	for ( scale = 1.0; scale <= 4.0; scale += 1.0 )
	{
	  cairo_save (cr);

	  cairo_scale (cr, scale, scale);

	  layout = pango_cairo_create_layout (cr);

	  desc = pango_font_description_new ();
	  pango_font_description_set_family (desc, "Sans");
	  pango_font_description_set_weight (desc, PANGO_WEIGHT_NORMAL);
	  pango_font_description_set_style  (desc, PANGO_STYLE_NORMAL);
	  pango_font_description_set_size   (desc, 14.0 * PANGO_SCALE);
	  pango_layout_set_font_description (layout, desc);
	  pango_font_description_free       (desc);

	  text = g_strdup_printf( "Text Test To, scale = %g\n", scale);
	  pango_layout_set_text (layout, text, -1);

	  cairo_set_source_rgb (cr, 0, 0, 0);
	  pango_cairo_show_layout (cr, layout);

	  g_object_unref (layout);
	  g_free (text);

	  cairo_restore (cr);

	  cairo_translate (cr, 0, scale*20);
	}
}



static gboolean
draw_cb (GtkWidget      *canvas,
	 cairo_t        *cr)
{
        demo_draw(cr);
        return FALSE;
}



int
main (int argc, char **argv)
{
	GtkWidget *window;
	GtkWidget *canvas;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	
	canvas = gtk_drawing_area_new ();
	gtk_container_add (GTK_CONTAINER (window), canvas);

	g_signal_connect (canvas, "draw",
			  G_CALLBACK (draw_cb), NULL);

	g_signal_connect (window, "destroy",
			  G_CALLBACK (gtk_main_quit), NULL);

	gtk_widget_show_all (window);

	gtk_main ();
}
