Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnumeric/configure.in,v
retrieving revision 1.654
diff -u -r1.654 configure.in
--- configure.in	9 Sep 2004 04:35:47 -0000	1.654
+++ configure.in	21 Sep 2004 20:02:06 -0000
@@ -493,6 +493,13 @@
   marker_no="<`$TPUT_CMD bold`no`$TPUT_CMD sgr0`  >"
 fi
 
+dnl We do not want to force libgnomeprint 2.8 just yet.
+SAVE_LIBS="$LIBS"
+LIBS="$LIBS $GNUMERIC_LIBS"
+AC_CHECK_FUNCS(gnome_print_pango_create_layout)
+LIBS="$SAVE_LIBS"
+unset SAVE_LIBS
+
 dnl
 dnl On Solaris finite() needs ieeefp.h
 dnl Either of these seem to signal IEEE754 math, see mathfunc.c
@@ -525,8 +532,6 @@
 
 dnl check for complete locale implementation
 AC_CHECK_HEADERS(langinfo.h)
-dnl iswprint/iswspace are sometimes in wctype.h
-AC_CHECK_HEADERS(wctype.h)
 
 dnl We supply our own lgamma_r (using lgamma) when missing.
 dnl We supply our own expm1 (using log1p) when missing.
Index: src/print.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/print.c,v
retrieving revision 1.162
diff -u -r1.162 print.c
--- src/print.c	7 Sep 2004 05:49:47 -0000	1.162
+++ src/print.c	21 Sep 2004 20:02:06 -0000
@@ -34,6 +34,9 @@
 
 #include <libgnomeprint/gnome-print-job.h>
 #include <libgnomeprint/gnome-print-config.h>
+#ifdef HAVE_GNOME_PRINT_PANGO_CREATE_LAYOUT
+#include <libgnomeprint/gnome-print-pango.h>
+#endif
 #include <libgnomeprintui/gnome-print-job-preview.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 
@@ -252,6 +255,13 @@
 	MIDDLE_HEADER
 } HFSide;
 
+static const PangoAlignment hfside_to_alignment[] = {
+	PANGO_ALIGN_LEFT,
+	PANGO_ALIGN_RIGHT,
+	PANGO_ALIGN_CENTER
+};
+
+
 /*
  * print_hf_element
  * @pj: printing context
@@ -269,13 +279,7 @@
 		  HFSide side, double y)
 {
 	char *text;
-	double x;
-	double len;
-	double header = 0, footer = 0, left = 0, right = 0;
 
-	/* Be really really anal in case Bug
-	 * http://bugs.gnome.org/db/82/8200.html exists
-	 */
 	g_return_if_fail (pj != NULL);
 	g_return_if_fail (pj->decoration_font != NULL);
 	g_return_if_fail (pj->render_info != NULL);
@@ -284,32 +288,56 @@
 
 	g_return_if_fail (text != NULL);
 
-	if (text [0] == 0) {
-		g_free (text);
-		return;
-	}
-
-	len = gnome_font_get_width_utf8 (pj->decoration_font, text);
-
-	print_info_get_margins   (pj->pi, &header, &footer, &left, &right);
-	switch (side){
-	case LEFT_HEADER:
-		x = left;
-		break;
-
-	case RIGHT_HEADER:
-		x = pj->width - right - len;
-		break;
-
-	case MIDDLE_HEADER:
-		x = (pj->x_points - len)/2 + left;
-		break;
-
-	default:
-		x = 0;
+	if (text[0]) {
+#ifdef HAVE_GNOME_PRINT_PANGO_CREATE_LAYOUT
+		const double dummy_dpi = 300; /* FIXME: What exactly is this?  */
+		PangoLayout *layout =
+			gnome_print_pango_create_layout (pj->print_context);
+		PangoFontDescription *pango_font =
+			gnome_font_get_pango_description (pj->decoration_font, dummy_dpi);
+		int height;
+		double header = 0, footer = 0, left = 0, right = 0;
+
+		print_info_get_margins (pj->pi, &header, &footer, &left, &right);
+		pango_layout_set_alignment (layout,
+					    hfside_to_alignment[side]);
+		pango_layout_set_font_description (layout, pango_font);
+		pango_layout_set_width (layout, (pj->width - left - right) * PANGO_SCALE);
+		pango_layout_set_text (layout, text, -1);
+
+		pango_layout_get_size (layout, NULL, &height);
+
+		gnome_print_moveto (pj->print_context,
+				    left,
+				    y + height / (double)PANGO_SCALE);
+		gnome_print_pango_layout (pj->print_context, layout);
+
+		g_object_unref (layout);
+		pango_font_description_free (pango_font);
+#else
+		/* This code will die when we require libgnomeprint 2.8  */
+		double x;
+		double len = gnome_font_get_width_utf8 (pj->decoration_font, text);
+		double header = 0, footer = 0, left = 0, right = 0;
+
+		print_info_get_margins (pj->pi, &header, &footer, &left, &right);
+		switch (side){
+		case LEFT_HEADER:
+			x = left;
+			break;
+		case RIGHT_HEADER:
+			x = pj->width - right - len;
+			break;
+		case MIDDLE_HEADER:
+			x = (pj->x_points - len) / 2 + left;
+			break;
+		default:
+			x = 0;
+		}
+		gnome_print_moveto (pj->print_context, x, y);
+		gnome_print_show (pj->print_context, text);
+#endif
 	}
-	gnome_print_moveto (pj->print_context, x, y);
-	gnome_print_show (pj->print_context, text);
 	g_free (text);
 }
 
