Index: src/cut-n-paste-code/goffice/graph/gog-renderer-gnome-print.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/cut-n-paste-code/goffice/graph/gog-renderer-gnome-print.c,v
retrieving revision 1.29
diff -u -r1.29 gog-renderer-gnome-print.c
--- src/cut-n-paste-code/goffice/graph/gog-renderer-gnome-print.c	13 Aug 2004 22:04:24 -0000	1.29
+++ src/cut-n-paste-code/goffice/graph/gog-renderer-gnome-print.c	22 Sep 2004 09:49:50 -0000
@@ -39,6 +39,10 @@
 #include <math.h>
 #include <string.h>
 
+#ifdef HAVE_GNOME_PRINT_PANGO_CREATE_LAYOUT
+#include <libgnomeprint/gnome-print-pango.h>
+#endif
+
 #define GOG_RENDERER_GNOME_PRINT_TYPE	(gog_renderer_gnome_print_get_type ())
 #define GOG_RENDERER_GNOME_PRINT(o)	(G_TYPE_CHECK_INSTANCE_CAST ((o), GOG_RENDERER_GNOME_PRINT_TYPE, GogRendererGnomePrint))
 #define IS_GOG_RENDERER_GNOME_PRINT(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GOG_RENDERER_GNOME_PRINT_TYPE))
@@ -405,49 +409,75 @@
 {
 	GogRendererGnomePrint *prend = GOG_RENDERER_GNOME_PRINT (rend);
 	GnomeFont *gfont = get_font (prend,  rend->cur_style->font.font);
+#ifndef HAVE_GNOME_PRINT_PANGO_CREATE_LAYOUT
 	double const font_ascent = gnome_font_get_ascender (gfont);
+#endif
 	double x, y, w, h;
 
-	w = gnome_font_get_width_utf8 (gfont, text);
-	h = font_ascent + gnome_font_get_descender (gfont);
-
-	x = pos->x;
-	switch (anchor) {
-	case GTK_ANCHOR_CENTER : case GTK_ANCHOR_N : case GTK_ANCHOR_S :
-		x -= w / 2;
-		break;
-	case GTK_ANCHOR_NE : case GTK_ANCHOR_SE : case GTK_ANCHOR_E :
-		x -= w;
-		break;
-	default : break;
-	}
-	if (x <= 0)
-		x = 0;
-
-	y = pos->y;
-	switch (anchor) {
-	case GTK_ANCHOR_CENTER : case GTK_ANCHOR_E : case GTK_ANCHOR_W :
-		y -= h / 2;
-		break;
-	case GTK_ANCHOR_SE : case GTK_ANCHOR_S : case GTK_ANCHOR_SW :
-		y -= h;
-		break;
-	default : break;
-	}
-	if (y <= 0)
-		y = 0;
-
-#warning add clipping
-
-	gnome_print_setfont (prend->gp_context, gfont);
-	gnome_print_moveto (prend->gp_context, x, -y - font_ascent);
-	gnome_print_show (prend->gp_context, text);
-
-	if (result != NULL) {
-		result->x = x;
-		result->y = y;
-		result->w = w;
-		result->h = h;
+	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 (prend->gp_context);
+		PangoFontDescription *pango_font =   /* FIXME: can i get the pango font directly ? */
+			gnome_font_get_pango_description (gfont, dummy_dpi);
+		
+		pango_layout_set_font_description (layout, pango_font);
+		pango_layout_set_text (layout, text, -1);
+
+		pango_layout_get_size (layout, &w, &h);
+
+#else
+		/* This code will die when we require libgnomeprint 2.8  */
+		w = gnome_font_get_width_utf8 (gfont, text);
+		h = font_ascent + gnome_font_get_descender (gfont);
+#endif	
+		x = pos->x;
+		switch (anchor) {
+		case GTK_ANCHOR_CENTER : case GTK_ANCHOR_N : case GTK_ANCHOR_S :
+			x -= w / 2;
+			break;
+		case GTK_ANCHOR_NE : case GTK_ANCHOR_SE : case GTK_ANCHOR_E :
+			x -= w;
+			break;
+		default : break;
+		}
+		if (x <= 0)
+			x = 0;
+	
+		y = pos->y;
+		switch (anchor) {
+		case GTK_ANCHOR_CENTER : case GTK_ANCHOR_E : case GTK_ANCHOR_W :
+			y -= h / 2;
+			break;
+		case GTK_ANCHOR_SE : case GTK_ANCHOR_S : case GTK_ANCHOR_SW :
+			y -= h;
+			break;
+		default : break;
+		}
+		if (y <= 0)
+			y = 0;
+		
+		#warning add clipping
+
+#ifdef HAVE_GNOME_PRINT_PANGO_CREATE_LAYOUT
+		gnome_print_moveto (prend->gp_context,x, -y);
+		gnome_print_pango_layout (prend->gp_context, layout);
+
+		g_object_unref (layout);
+		pango_font_description_free (pango_font);
+#else	
+		/* This code will die when we require libgnomeprint 2.8  */		
+		gnome_print_setfont (prend->gp_context, gfont);
+		gnome_print_moveto (prend->gp_context, x, -y - font_ascent);
+		gnome_print_show (prend->gp_context, text);
+#endif	
+		if (result != NULL) {
+			result->x = x;
+			result->y = y;
+			result->w = w;
+			result->h = h;
+		}
 	}
 }
 
