[evolution-patches] Patch for 69430: addressbook printing using gnome_print_pango_layout



I just attached a first attempt at a patch for this; it's still got
some debug logging in it, but I can clean that up. (no ChangeLog or
configuration yet either, but I wanted some feedback)

This avoids using GnomeFont, and attempts to use Pango for all
text handling when printing address books.

I'm seeing addressbooks with considerably larger fonts after applying
this pacth; it appears that when e_contact_build_style loads
"medbook.ecps"; this is parsed to populate the EContactPrintStyle
struct; on FC3 when loading the various fonts e.g. header_font it gets
"Helvetica Bold 12", which it passes to gnome_font_face_find, which
returns NULL, hence the existing code is always simply using the
defaults at the top of e_contact_build_style (Sans Bold 8).
My version of the code manages to get at "Helvetica Bold 12" etc, so
everything is coming out at about 50% bigger (i.e. at 18 point rather
than point, allowing for the factor of 1.5 that gets applied)
Index: addressbook/printing/e-contact-print-types.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/printing/e-contact-print-types.h,v
retrieving revision 1.6
diff -u -p -r1.6 e-contact-print-types.h
--- addressbook/printing/e-contact-print-types.h	27 Oct 2001 16:41:29 -0000	1.6
+++ addressbook/printing/e-contact-print-types.h	16 Feb 2005 23:30:13 -0000
@@ -25,6 +25,18 @@
 #include <glib.h>
 #include <libgnomeprint/gnome-font.h>
 
+#define HAVE_GNOME_PRINT_PANGO_INTEGRATION 
+
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION 
+#include <libgnomeprint/gnome-print-pango.h>
+#endif
+
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+typedef PangoFontDescription EvoContactPrintFont;
+#else
+typedef GnomeFont EvoContactPrintFont;
+#endif
+
 typedef struct _EContactPrintStyle EContactPrintStyle;
 typedef enum _EContactPrintType EContactPrintType;
 
@@ -43,8 +55,8 @@ struct _EContactPrintStyle
 	guint blank_forms;
 	gboolean letter_tabs;
 	gboolean letter_headings;
-	GnomeFont *headings_font;
-	GnomeFont *body_font;
+	EvoContactPrintFont *headings_font;
+	EvoContactPrintFont *body_font;
 	gboolean print_using_grey;
 	gint paper_type;
 	gdouble paper_width;
@@ -58,11 +70,11 @@ struct _EContactPrintStyle
 	gdouble page_width;
 	gdouble page_height;
 	gboolean orientation_portrait;
-	GnomeFont *header_font;
+	EvoContactPrintFont *header_font;
 	gchar *left_header;
 	gchar *center_header;
 	gchar *right_header;
-	GnomeFont *footer_font;
+	EvoContactPrintFont *footer_font;
 	gchar *left_footer;
 	gchar *center_footer;
 	gchar *right_footer;
Index: addressbook/printing/e-contact-print.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/printing/e-contact-print.c,v
retrieving revision 1.49
diff -u -p -r1.49 e-contact-print.c
--- addressbook/printing/e-contact-print.c	21 Jan 2005 21:05:13 -0000	1.49
+++ addressbook/printing/e-contact-print.c	16 Feb 2005 23:30:13 -0000
@@ -53,6 +53,9 @@ struct _EContactPrintContext
 {
 	GnomePrintContext *pc;
 	GnomePrintJob     *master;
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	PangoLayout *pl;
+#endif
 	gdouble x;
 	gdouble y;
 	gint column;
@@ -60,8 +63,9 @@ struct _EContactPrintContext
 	gboolean first_section;
 	gchar first_char_on_page;
 	gchar last_char_on_page;
-	GnomeFont *letter_heading_font;
-	GnomeFont *letter_tab_font;
+
+	EvoContactPrintFont *letter_heading_font;
+	EvoContactPrintFont *letter_tab_font;
 	char *character;
 	gboolean first_contact;
 
@@ -73,10 +77,151 @@ struct _EContactPrintContext
 	GList *contacts;
 };
 
+static double
+evo_contact_print_font_get_height (EvoContactPrintFont *font)
+{
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	return (double)pango_font_description_get_size (font)/(double)PANGO_SCALE;
+#else
+	return gnome_font_get_size (font);
+#endif
+}
+
+static double
+evo_contact_print_font_get_width_utf8 (EContactPrintContext *context, EvoContactPrintFont *font, const char *text)
+{
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	int width;
+	int height;
+#endif
+
+	g_return_val_if_fail (font, 0.0);
+	g_return_val_if_fail (text, 0.0);
+
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	g_assert (context->pl);
+	pango_layout_set_font_description (context->pl, font);
+	pango_layout_set_text (context->pl, text, -1);
+	pango_layout_set_width (context->pl, -1);
+	pango_layout_set_indent (context->pl, 0);
+
+	pango_layout_get_size (context->pl,
+			       &width,
+			       &height);
+
+	return (double)width/(double)PANGO_SCALE;
+#else
+	return gnome_font_get_width_utf8 (font, text);
+#endif
+}
+
+static EvoContactPrintFont*
+evo_contact_print_font_find (const char *name, double height)
+{
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	PangoFontDescription *desc = pango_font_description_new ();
+	pango_font_description_set_family (desc, name);	
+	pango_font_description_set_size (desc, height * PANGO_SCALE);	
+
+	{
+		char *tmp = pango_font_description_to_string (desc);
+		g_message ("evo_contact_print_font_find(%s,%f) returning %s", name, height, tmp);
+		g_free (tmp);
+	}
+
+	return desc;
+#else
+	GnomeFont *font = gnome_font_find (name, height);
+	g_message ("evo_contact_print_font_find(%s,%f) giving font size %f", name, height, gnome_font_get_size (font));
+	return font;
+#endif
+}
+
+static const char*
+evo_contact_print_font_get_name (EvoContactPrintFont *font)
+{
+	const char *name;
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	name = pango_font_description_get_family (font);
+#else
+	name = gnome_font_get_name (font);
+#endif
+	g_message ("evo_contact_print_font_get_name returning %s", name);
+
+	return name;
+}
+
+static EvoContactPrintFont*
+evo_contact_print_font_find_closest_from_weight_slant (const guchar *family, GnomeFontWeight weight, gboolean italic, gdouble size)
+{
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	PangoFontDescription *desc = pango_font_description_new ();
+	pango_font_description_set_family (desc, family);	
+
+	/* GnomePrintWeight and PangoWeight values should be interchangeable: */
+	pango_font_description_set_weight (desc, (PangoWeight)weight);
+
+	if (italic) {
+		pango_font_description_set_style (desc, PANGO_STYLE_ITALIC);
+	}
+	pango_font_description_set_size (desc, size * PANGO_SCALE);
+	g_warning ("size %f gives font size: %f", size,  pango_font_description_get_size (desc)/(double)PANGO_SCALE);
+
+	{
+		char *tmp = pango_font_description_to_string (desc);
+		g_warning ("evo_contact_print_font_find_closest_from_weight_slant (%s, %d, %d, %f) gives %s ", family, weight, italic, size, tmp);
+		g_free (tmp);
+	}
+
+	return desc;
+#else
+	GnomeFont *font = gnome_font_find_closest_from_weight_slant (family, weight, italic, size);
+	g_warning ("size %f gives font size: %f", size, gnome_font_get_size (font));
+	return font;
+#endif
+}
+
+static void
+evo_contact_print_font_free(EvoContactPrintFont *font) 
+{
+	g_return_if_fail (font);
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	pango_font_description_free (font);
+#else
+	g_object_unref (G_OBJECT (font));
+#endif
+}
+
+static EvoContactPrintFont *
+evo_contact_print_font_find_from_full_name (const char *name)
+{
+	EvoContactPrintFont *font;
+
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	font = pango_font_description_from_string (name);
+
+	{
+		char *tmp = pango_font_description_to_string (font);
+		g_warning ("evo_contact_print_font_find_from_full_name (%s) gives %s ", name, tmp);
+		g_free (tmp);
+	}
+#else
+	font = gnome_font_find_from_full_name (name);
+
+	{ 
+		char *tmp = gnome_font_get_full_name(font);
+		g_warning ("evo_contact_print_font_find_from_full_name (%s) gives %s ", name, tmp );
+	}
+#endif
+
+	return font;
+}
+
+#ifndef HAVE_GNOME_PRINT_PANGO_INTEGRATION
 static gint
-e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text, GList **return_val /* Of type char[] */)
+e_contact_divide_text(EContactPrintContext *ctxt, EvoContactPrintFont *font, double width, const gchar *text, GList **return_val /* Of type char[] */)
 {
-	if ( width == -1 || gnome_font_get_width_utf8(font, text) <= width ) {
+	if ( width == -1 || evo_contact_print_font_get_width_utf8(ctxt,font, text) <= width ) {
 		if ( return_val ) {
 			*return_val = g_list_append(*return_val, g_strdup(text));
 		}
@@ -96,7 +241,7 @@ e_contact_divide_text(GnomePrintContext 
 					if (return_val) {
 						*return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart));
 					}
-					x = gnome_font_get_width_utf8(font, "    ");
+					x = evo_contact_print_font_get_width_utf8(ctxt,font, "    ");
 					linestart = lastend + 1;
 					x += gnome_font_get_width_utf8_sized(font, text + linestart, i - linestart);
 					lastend = i;
@@ -121,7 +266,7 @@ e_contact_divide_text(GnomePrintContext 
 				linestart = i + 1;
 				lastend = i + 1;
 				linecount ++;
-				x = gnome_font_get_width_utf8(font, "    ");
+				x = evo_contact_print_font_get_width_utf8(ctxt,font, "    ");
 
 				firstword = 1;
 			}
@@ -147,7 +292,7 @@ e_contact_divide_text(GnomePrintContext 
 		gint i;
 		gint l;
 		gchar *hyphenation;
-		double x = - gnome_font_get_width_utf8(font, "    ") * SCALE;
+		double x = - evo_contact_print_font_get_width_utf8(ctxt,font, "    ") * SCALE;
 		HnjParams hnjparams;
 
 		hnjparams.set_width = width * SCALE + x;
@@ -176,7 +321,7 @@ e_contact_divide_text(GnomePrintContext 
 	
 		for (i = 0; i < l; i++) {
 			if ( text[i] == '-' ) {
-				x += gnome_font_get_width(font, text[i]) * SCALE;
+				x += evo_contact_print_font_get_width(font, text[i]) * SCALE;
 				breaks[n_breaks].x0 = x;
 				breaks[n_breaks].x1 = x;
 				breaks[n_breaks].penalty = HYPHEN_PENALTY;
@@ -185,7 +330,7 @@ e_contact_divide_text(GnomePrintContext 
 				n_breaks++;
 			} else if ( text[i] == ' ' ) {
 				breaks[ n_breaks ].x0 = x;
-				x += gnome_font_get_width(font, text[i]) * SCALE;
+				x += evo_contact_print_font_get_width(font, text[i]) * SCALE;
 				breaks[ n_breaks ].x1 = x;
 				breaks[ n_breaks ].penalty = 0;
 				breaks[ n_breaks ].flags = HNJ_JUST_FLAG_ISSPACE;
@@ -193,7 +338,7 @@ e_contact_divide_text(GnomePrintContext 
 				n_breaks++;
 #if 0
 			} else if (word->hyphenation[i] & 1) {
-				breaks[n_breaks].x0 = x + gnome_font_get_width(font, '-') * SCALE;
+				breaks[n_breaks].x0 = x + evo_contact_print_font_get_width(font, '-') * SCALE;
 				breaks[n_breaks].x1 = x;
 				breaks[n_breaks].penalty = HYPHEN_PENALTY;
 				breaks[n_breaks].flags = HNJ_JUST_FLAG_ISHYPHEN;
@@ -201,7 +346,7 @@ e_contact_divide_text(GnomePrintContext 
 				n_breaks++;
 #endif
 			} else
-				x += gnome_font_get_width(font, text[i]) * SCALE;
+				x += evo_contact_print_font_get_width(font, text[i]) * SCALE;
 
 		}
 		is[n_breaks] = i;
@@ -248,47 +393,87 @@ e_contact_divide_text(GnomePrintContext 
 #endif
 	}
 }
+#endif
 
 static void
-e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, double width, const gchar *text)
+e_contact_output(EContactPrintContext *ctxt, EvoContactPrintFont *font, double x, double y, double width, const gchar *text)
 {
+#ifndef HAVE_GNOME_PRINT_PANGO_INTEGRATION
 	GList *list = NULL, *list_start;
 	int first_line = 1;
-	gnome_print_gsave(pc);
-	gnome_print_setfont(pc, font);
-	e_contact_divide_text(pc, font, width, text, &list);
+#endif
+
+	gnome_print_gsave(ctxt->pc);
+
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	/* Preserve the indentation behaviour of e_contact_divide_text: */
+	double indent;
+	if ( width == -1 || evo_contact_print_font_get_width_utf8(ctxt, font, text) <= width ) {
+		indent = 0.0;
+	} else {
+		indent = evo_contact_print_font_get_width_utf8 (ctxt, font, "    ");	
+	} 	
+
+	g_assert (ctxt->pl);
+	pango_layout_set_font_description (ctxt->pl, font);
+	pango_layout_set_text (ctxt->pl, text, -1);
+	pango_layout_set_width (ctxt->pl, width*PANGO_SCALE);
+	pango_layout_set_indent (ctxt->pl, indent*PANGO_SCALE);
+
+	gnome_print_moveto(ctxt->pc, x, y);
+	gnome_print_pango_layout (ctxt->pc, ctxt->pl);
+#else
+ 	gnome_print_setfont(ctxt->pc, font);
+	e_contact_divide_text(ctxt, font, width, text, &list);
 	for ( list_start = list; list; list = g_list_next(list)) {
 		y -= gnome_font_get_ascender(font);
-		gnome_print_moveto(pc, x, y);
-		gnome_print_show(pc, (char *)list->data);
+		gnome_print_moveto(ctxt->pc, x, y);
+		gnome_print_show(ctxt->pc, (char *)list->data);
 		y -= gnome_font_get_descender(font);
-		y -= .2 * gnome_font_get_size (font);
+		y -= .2 * evo_contact_print_font_get_height (font);
 		if ( first_line ) {
-			x += gnome_font_get_width_utf8(font, "    ");
+			x += evo_contact_print_font_get_width_utf8(ctxt,font, "    ");
 			first_line = 0;
 		}
 	}
 	g_list_foreach( list_start, (GFunc) g_free, NULL );
 	g_list_free( list_start );
-	gnome_print_grestore(pc);
+#endif
+	gnome_print_grestore(ctxt->pc);
 }
 
 static gdouble
-e_contact_text_height(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text)
+e_contact_text_height(EContactPrintContext *ctxt, EvoContactPrintFont *font, double width, const gchar *text)
 {
-	int line_count = e_contact_divide_text(pc, font, width, text, NULL);
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	gint w, h;
+
+	g_assert (ctxt->pl);
+	pango_layout_set_font_description (ctxt->pl, font);
+	pango_layout_set_text (ctxt->pl, text, -1);
+	pango_layout_set_width (ctxt->pl, width*PANGO_SCALE);
+	pango_layout_set_indent (ctxt->pl, 0);
+
+	pango_layout_get_size (ctxt->pl,
+			       &w,
+			       &h);
+
+	return (double)h/(double)PANGO_SCALE;
+#else
+	int line_count = e_contact_divide_text(ctxt, font, width, text, NULL);
 	return line_count * (gnome_font_get_ascender(font) + gnome_font_get_descender(font)) +
-		(line_count - 1) * .2 * gnome_font_get_size (font);
+		(line_count - 1) * .2 * evo_contact_print_font_get_height (font);
+#endif
 }
 
 #if 0
 static void
-e_contact_output_and_advance(EContactPrintContext *ctxt, GnomeFont *font, double x, double width, gchar *text)
+e_contact_output_and_advance(EContactPrintContext *ctxt, EvoContactPrintFont *font, double x, double width, gchar *text)
 {
-	ctxt->y -= .1 * gnome_font_get_size (font);
+	ctxt->y -= .1 * evo_contact_print_font_get_height (font);
 	e_contact_output(ctxt->pc, font, x, ctxt->y, width, text);
 	ctxt->y -= e_contact_text_height(ctxt->pc, font, width, text);
-	ctxt->y -= .1 * gnome_font_get_size (font);
+	ctxt->y -= .1 * evo_contact_print_font_get_height (font);
 }
 #endif
 
@@ -316,7 +501,7 @@ e_contact_rectangle(GnomePrintContext *p
 static double
 e_contact_get_letter_tab_width (EContactPrintContext *ctxt)
 {
-	return gnome_font_get_width_utf8(ctxt->letter_tab_font, "123") + 4 + 18;
+	return evo_contact_print_font_get_width_utf8(ctxt, ctxt->letter_tab_font, "123") + 4 + 18;
 }
 
 static double
@@ -346,41 +531,48 @@ e_contact_print_letter_tab (EContactPrin
 		if ( character >= ctxt->first_char_on_page && character <= ctxt->last_char_on_page ) {
 			e_contact_rectangle( ctxt->pc, x + 1, y - 1, x + tab_width - 1, y - (tab_height - 1), 0, 0, 0 );
 			gnome_print_setrgbcolor( ctxt->pc, 1, 1, 1 );
-			e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_utf8(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
+			e_contact_output( ctxt, ctxt->letter_tab_font, x + tab_width / 2 - evo_contact_print_font_get_width_utf8(ctxt, ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
 		} else {
 			gnome_print_setrgbcolor( ctxt->pc, 0, 0, 0 );
-			e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_utf8(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
+			e_contact_output( ctxt, ctxt->letter_tab_font, x + tab_width / 2 - evo_contact_print_font_get_width_utf8(ctxt, ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string );
 		}
 		y -= tab_height;
 	}
 	gnome_print_grestore( ctxt->pc );
-	return gnome_font_get_width_utf8(ctxt->style->body_font, "123") + gnome_font_get_size (ctxt->style->body_font) / 5;
+	return evo_contact_print_font_get_width_utf8(ctxt, ctxt->style->body_font, "123") + evo_contact_print_font_get_height (ctxt->style->body_font) / 5;
 }
 
 static double
 e_contact_get_letter_heading_height (EContactPrintContext *ctxt)
 {
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	return evo_contact_print_font_get_height (ctxt->letter_heading_font);
+#else
 	gdouble ascender, descender;
 	ascender = gnome_font_get_ascender(ctxt->letter_heading_font);
 	descender = gnome_font_get_descender(ctxt->letter_heading_font);
 	return ascender + descender + 9;
+#endif
 }
 
 static void
 e_contact_print_letter_heading (EContactPrintContext *ctxt, gchar *character)
 {
-	gdouble ascender, descender;
+	gdouble height;
 	gdouble width;
 
-	width = gnome_font_get_width_utf8(ctxt->letter_heading_font, "m") * 1.7;
-	ascender = gnome_font_get_ascender(ctxt->letter_heading_font);
-	descender = gnome_font_get_descender(ctxt->letter_heading_font);
+	width = evo_contact_print_font_get_width_utf8(ctxt, ctxt->letter_heading_font, "m") * 1.7;
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	height = evo_contact_print_font_get_height (ctxt->letter_heading_font);
+#else
+	height = gnome_font_get_ascender(ctxt->letter_heading_font) + gnome_font_get_descender(ctxt->letter_heading_font);
+#endif
 	gnome_print_gsave( ctxt->pc );
-	e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (ascender + descender + 6), 0, 0, 0);
+	e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (height + 6), 0, 0, 0);
 	gnome_print_setrgbcolor(ctxt->pc, 1, 1, 1);
 	ctxt->y -= 4;
-	e_contact_output(ctxt->pc, ctxt->letter_heading_font, ctxt->x + (width - gnome_font_get_width_utf8(ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character);
-	ctxt->y -= ascender + descender;
+	e_contact_output(ctxt, ctxt->letter_heading_font, ctxt->x + (width - evo_contact_print_font_get_width_utf8(ctxt, ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character);
+	ctxt->y -= height;
 	ctxt->y -= 2;
 	ctxt->y -= 3;
 	gnome_print_grestore( ctxt->pc );
@@ -413,31 +605,31 @@ e_contact_get_contact_size(EContact *con
 		page_width -= e_contact_get_letter_tab_width(ctxt);
 	column_width = (page_width + 18) / ctxt->style->num_columns - 18;
 
-	height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+	height += evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 
-	height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+	height += evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 
 	file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS);
 
-	height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
+	height += e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as);
 
-	height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+	height += evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 
-	height += gnome_font_get_size (ctxt->style->headings_font) * .2;
+	height += evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 	
 	for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) {
 		char *string;
 		string = e_contact_get(contact, field);
 		if (string && *string) {
 			double xoff = 0;
-			xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field));
-			xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ":  ");
-			height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
-			height += .2 * gnome_font_get_size (ctxt->style->body_font);
+			xoff += evo_contact_print_font_get_width_utf8(ctxt, ctxt->style->body_font, e_contact_pretty_name (field));
+			xoff += evo_contact_print_font_get_width_utf8(ctxt, ctxt->style->body_font, ":  ");
+			height += e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string);
+			height += .2 * evo_contact_print_font_get_height (ctxt->style->body_font);
 		}
 		g_free(string);
 	}
-	height += gnome_font_get_size (ctxt->style->headings_font) * .4;
+	height += evo_contact_print_font_get_height (ctxt->style->headings_font) * .4;
 
 	/* g_message ("%s %g", e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_FILE_AS), height); */
 	return height;
@@ -458,18 +650,18 @@ e_contact_print_contact (EContact *conta
 
 	gnome_print_gsave(ctxt->pc);
 
-	ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
-	ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
+	ctxt->y -= evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
+	ctxt->y -= evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 
 	file_as = e_contact_get (contact, E_CONTACT_FILE_AS);
 	if (ctxt->style->print_using_grey)
-		e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + gnome_font_get_size (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as) - gnome_font_get_size (ctxt->style->headings_font) * .3, .85, .85, .85);
-	e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as);
-	ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
+		e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + evo_contact_print_font_get_height (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as) - evo_contact_print_font_get_height (ctxt->style->headings_font) * .3, .85, .85, .85);
+	e_contact_output(ctxt, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as);
+	ctxt->y -= e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as);
 	g_free (file_as);
 
-	ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
-	ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2;
+	ctxt->y -= evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
+	ctxt->y -= evo_contact_print_font_get_height (ctxt->style->headings_font) * .2;
 	
 	for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) {
 		char *string;
@@ -477,18 +669,18 @@ e_contact_print_contact (EContact *conta
 
 		if (string && *string) {
 			double xoff = 0;
-			e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field));
-			xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field));
-			e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ":  ");
-			xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ":  ");
-			e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string);
-			ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
-			ctxt->y -= .2 * gnome_font_get_size (ctxt->style->body_font);
+			e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field));
+			xoff += evo_contact_print_font_get_width_utf8(ctxt, ctxt->style->body_font, e_contact_pretty_name (field));
+			e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ":  ");
+			xoff += evo_contact_print_font_get_width_utf8(ctxt, ctxt->style->body_font, ":  ");
+			e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string);
+			ctxt->y -= e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string);
+			ctxt->y -= .2 * evo_contact_print_font_get_height (ctxt->style->body_font);
 		}
 		g_free(string);
 	}
 	
-	ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .4;
+	ctxt->y -= evo_contact_print_font_get_height (ctxt->style->headings_font) * .4;
 	gnome_print_grestore(ctxt->pc);
 }
 
@@ -585,12 +777,12 @@ complete_sequence(EBookView *book_view, 
 		e_book_query_unref (ctxt->query);
 	g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL);
 	g_list_free(ctxt->contacts);
-	g_object_unref(ctxt->style->headings_font);
-	g_object_unref(ctxt->style->body_font);
-	g_object_unref(ctxt->style->header_font);
-	g_object_unref(ctxt->style->footer_font);
-	g_object_unref(ctxt->letter_heading_font);
-	g_object_unref(ctxt->letter_tab_font);
+	evo_contact_print_font_free(ctxt->style->headings_font);
+	evo_contact_print_font_free(ctxt->style->body_font);
+	evo_contact_print_font_free(ctxt->style->header_font);
+	evo_contact_print_font_free(ctxt->style->footer_font);
+	evo_contact_print_font_free(ctxt->letter_heading_font);
+	evo_contact_print_font_free(ctxt->letter_tab_font);
 	g_free(ctxt->style);
 	g_free(ctxt);
 }
@@ -701,12 +893,12 @@ static double get_float( char *data )
 		return 0;
 }
 
-static void get_font( char *data, GnomeFont **variable )
+static void get_font( char *data, EvoContactPrintFont **variable )
 {
 	if ( data ) {
-		GnomeFont *font = gnome_font_find_from_full_name( data );
+		EvoContactPrintFont *font = evo_contact_print_font_find_from_full_name( data );
 		if ( font ) {
-			g_object_unref(*variable);
+			evo_contact_print_font_free(*variable);
 			*variable = font;
 		}
 	}
@@ -727,8 +919,8 @@ e_contact_build_style(EContactPrintStyle
 	style->letter_tabs = TRUE;
 	style->letter_headings = FALSE;
 
-	style->headings_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOLD, FALSE, 8);
-	style->body_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+	style->headings_font = evo_contact_print_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOLD, FALSE, 8);
+	style->body_font = evo_contact_print_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
 
 	style->print_using_grey = TRUE;
 	style->paper_type = 0;
@@ -752,13 +944,13 @@ e_contact_build_style(EContactPrintStyle
 #endif
 	style->orientation_portrait = FALSE;
 
-	style->header_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+	style->header_font = evo_contact_print_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
 
 	style->left_header = g_strdup("");
 	style->center_header = g_strdup("");
 	style->right_header = g_strdup("");
 
-	style->footer_font = gnome_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
+	style->footer_font = evo_contact_print_font_find_closest_from_weight_slant ("Sans", GNOME_FONT_BOOK, FALSE, 6);
 
 	style->left_footer = g_strdup("");
 	style->center_footer = g_strdup("");
@@ -897,10 +1089,13 @@ e_contact_print_response(GtkWidget *dial
 		ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PRINT;
 
 		font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
-		ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
-		ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+		ctxt->letter_heading_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), evo_contact_print_font_get_height(ctxt->style->headings_font)*1.5);
+		ctxt->letter_tab_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), font_size);
 	
 		ctxt->pc = pc;
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+		ctxt->pl = gnome_print_pango_create_layout (pc);
+#endif
 #warning FIXME gnome_print_multipage_new_from_sizes
 #if 0
 		ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, 
@@ -943,8 +1138,8 @@ e_contact_print_response(GtkWidget *dial
 		ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW;
 
 		font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
-		ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
-		ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+		ctxt->letter_heading_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), evo_contact_print_font_get_height (ctxt->style->headings_font) * 1.5);
+		ctxt->letter_tab_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), font_size);
 		
 		ctxt->pc = pc;
 #warning FIXME gnome_print_multipage_new_from_sizes
@@ -986,6 +1181,10 @@ e_contact_print_response(GtkWidget *dial
 		        e_book_query_unref (query);
 
 		gtk_widget_destroy (dialog);
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+		g_assert (ctxt->pl);
+		g_object_unref (G_OBJECT(ctxt->pl));
+#endif
 		g_free(style);
 		g_free(ctxt);
 		break;
@@ -1039,10 +1238,13 @@ e_contact_print_preview(EBook *book, cha
 	ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW;
 
 	font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
-	ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5);
-	ctxt->letter_tab_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), font_size);
+	ctxt->letter_heading_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), evo_contact_print_font_get_height (ctxt->style->headings_font) * 1.5);
+	ctxt->letter_tab_font = evo_contact_print_font_find (evo_contact_print_font_get_name(ctxt->style->headings_font), font_size);
 
-		ctxt->pc = pc;
+	ctxt->pc = pc;
+#ifdef HAVE_GNOME_PRINT_PANGO_INTEGRATION
+	ctxt->pl = gnome_print_pango_create_layout (pc);
+#endif
 #warning FIXME gnome_print_multipage_new_from_sizes
 #if 0
 	ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]