[evolution-patches] gtkhtml: printing fix



Attached patch enlarges page margins and contains updates for changed
descender sign (it's negative value in gnome 2 gnome print)

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1795
diff -u -p -r1.1795 ChangeLog
--- ChangeLog	15 May 2003 20:26:35 -0000	1.1795
+++ ChangeLog	16 May 2003 13:28:12 -0000
@@ -1,3 +1,16 @@
+2003-05-16  Radek Doulik  <rodo ximian com>
+
+	* testgtkhtml.c (print_preview_cb): as below
+
+	* htmlprinter.c (draw_text): descender is negative value in
+	gnome2, code updated
+	(calc_text_size): ditto
+	(calc_text_size_bytes): ditto
+
+	* htmlengine-print.c: remove SPACING_FACTOR - not needed and broken, 
+
+	* htmlprinter.c (TEMP_MARGIN): increase margins a little bit
+
 2003-05-13  Larry Ewing  <lewing ximian com>
 
 	* htmlfontmanager.c (html_font_manager_set_default): clear both
Index: htmlengine-print.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-print.c,v
retrieving revision 1.36
diff -u -p -r1.36 htmlengine-print.c
--- htmlengine-print.c	8 Nov 2002 14:50:14 -0000	1.36
+++ htmlengine-print.c	16 May 2003 13:28:15 -0000
@@ -43,11 +43,9 @@ print_header_footer (HTMLPainter *painte
 	gdouble gx, gy;
 
 	gnome_print_gsave (context);
-	html_painter_set_clip_rectangle (painter, 0, y,
-					 width, SCALE_GNOME_PRINT_TO_ENGINE (height));
+	html_painter_set_clip_rectangle (painter, 0, y, width, SCALE_GNOME_PRINT_TO_ENGINE (height));
 #ifdef CLIP_DEBUG
-	html_painter_draw_rect (painter, 0, y,
-				SCALE_GNOME_PRINT_TO_ENGINE (width), SCALE_GNOME_PRINT_TO_ENGINE (height));
+	html_painter_draw_rect (painter, 0, y, width, SCALE_GNOME_PRINT_TO_ENGINE (height));
 #endif
 	html_printer_coordinates_to_gnome_print (printer, 0, y, &gx, &gy);
 	(*cb) (GTK_HTML (engine->widget), context, gx, gy, SCALE_ENGINE_TO_GNOME_PRINT (width), height, user_data);
Index: htmlprinter.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlprinter.c,v
retrieving revision 1.64
diff -u -p -r1.64 htmlprinter.c
--- htmlprinter.c	19 Mar 2003 04:21:56 -0000	1.64
+++ htmlprinter.c	16 May 2003 13:28:16 -0000
@@ -42,9 +42,6 @@ static HTMLPainterClass *parent_class = 
 /* The size of a pixel in the printed output, in points.  */
 #define PIXEL_SIZE .5
 
-/* Hm, this might need fixing.  */
-#define SPACING_FACTOR 1.2
-
 static void
 insure_config (HTMLPrinter *p)
 {
@@ -75,7 +72,7 @@ printer_get_page_width (HTMLPrinter *pri
 	return width;
 }
 
-#define TEMP_MARGIN .05
+#define TEMP_MARGIN .06
 
 static gdouble
 get_lmargin (HTMLPrinter *printer)
@@ -567,10 +564,9 @@ draw_text (HTMLPainter *painter, gint x,
 
 	bytes = g_utf8_offset_to_pointer (text, len) - text;
 	font = html_painter_get_font (painter, painter->font_face, painter->font_style);
-	dsc = gnome_font_get_descender (font);
+	dsc = -gnome_font_get_descender (font);
 	asc = gnome_font_get_ascender (font);
 	html_printer_coordinates_to_gnome_print (printer, x, y, &print_x, &print_y);
-	print_y -= dsc;
 
 	gnome_print_newpath (printer->context);
 	gnome_print_moveto (printer->context, print_x, print_y);
@@ -665,8 +661,8 @@ calc_text_size (HTMLPainter *painter, co
 
 	*width = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_width_utf8_sized (font, text,
 									       g_utf8_offset_to_pointer (text, len) - text));
-	*asc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_ascender (font) * SPACING_FACTOR);
-	*dsc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_descender (font) * SPACING_FACTOR);
+	*asc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_ascender (font));
+	*dsc = SCALE_GNOME_PRINT_TO_ENGINE (-gnome_font_get_descender (font));
 }
 
 static void
@@ -680,8 +676,8 @@ calc_text_size_bytes (HTMLPainter *paint
 	g_return_if_fail (font != NULL);
 
 	*width = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_width_utf8_sized (font->data, text, len));
-	*asc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_ascender (font->data) * SPACING_FACTOR);
-	*dsc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_descender (font->data) * SPACING_FACTOR);
+	*asc = SCALE_GNOME_PRINT_TO_ENGINE (gnome_font_get_ascender (font->data));
+	*dsc = SCALE_GNOME_PRINT_TO_ENGINE (-gnome_font_get_descender (font->data));
 }
 
 static guint
Index: testgtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/testgtkhtml.c,v
retrieving revision 1.111
diff -u -p -r1.111 testgtkhtml.c
--- testgtkhtml.c	22 Jan 2003 15:13:59 -0000	1.111
+++ testgtkhtml.c	16 May 2003 13:28:17 -0000
@@ -308,9 +308,9 @@ print_preview_cb (GtkWidget *widget,
 
 	page_num = 1;
 	pages = gtk_html_print_get_pages_num (html, print_context,
-					      .0, gnome_font_get_ascender (font) + gnome_font_get_descender (font));
+					      .0, gnome_font_get_ascender (font) - gnome_font_get_descender (font));
 	gtk_html_print_with_header_footer (html, print_context,
-					   .0, gnome_font_get_ascender (font) + gnome_font_get_descender (font),
+					   .0, gnome_font_get_ascender (font) - gnome_font_get_descender (font),
 					   NULL, print_footer, NULL);
 	if (font)
 		g_object_unref (font);


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