gtkhtml r9195 - trunk/gtkhtml



Author: tobiasmue
Date: Wed Apr  8 23:21:19 2009
New Revision: 9195
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=9195&view=rev

Log:
2009-04-09  Tobias Mueller  <tobiasmue svn gnome org>

    * gtkhtml.c (gtk_html_set_fonts):
    * htmlpainter.c (html_painter_alloc_font):
    Use the  boolean parameter "points" properly to know whether
    a font is point or pixel sized.

    * testgtkhtml.c (draw_page_cb):
    Have a testcase for that as well.

    Patch by Alexander Sack <asac jwsdot com>

    Fixes bug #576684



Modified:
   trunk/gtkhtml/ChangeLog
   trunk/gtkhtml/gtkhtml.c
   trunk/gtkhtml/htmlpainter.c
   trunk/gtkhtml/testgtkhtml.c

Modified: trunk/gtkhtml/gtkhtml.c
==============================================================================
--- trunk/gtkhtml/gtkhtml.c	(original)
+++ trunk/gtkhtml/gtkhtml.c	Wed Apr  8 23:21:19 2009
@@ -887,8 +887,10 @@
 	char *fixed_name = NULL;
 	const char *fixed_family = NULL;
 	gint  fixed_size = 0;
+	gboolean  fixed_points = FALSE;
 	const char *font_var = NULL;
 	gint  font_var_size = 0;
+	gboolean  font_var_points = FALSE;
 	cairo_font_options_t *font_options;
 
 	top_level = GTK_WIDGET (gtk_html_get_top_html (html));
@@ -896,12 +898,14 @@
 
 	font_var = pango_font_description_get_family (style->font_desc);
 	font_var_size = pango_font_description_get_size (style->font_desc);
+	font_var_points = !pango_font_description_get_size_is_absolute (style->font_desc);
 
 	gtk_widget_style_get (GTK_WIDGET (top_level), "fixed_font_name", &fixed_name, NULL);
 	if (fixed_name) {
 		fixed_desc = pango_font_description_from_string (fixed_name);
 		if (pango_font_description_get_family (fixed_desc)) {
 			fixed_size = pango_font_description_get_size (fixed_desc);
+			fixed_points = !pango_font_description_get_size_is_absolute (fixed_desc);
 			fixed_family = pango_font_description_get_family (fixed_desc);
 		} else {
 			g_free (fixed_name);
@@ -918,6 +922,7 @@
 			fixed_desc = pango_font_description_from_string (fixed_name);
 			if (fixed_desc) {
 				fixed_size = pango_font_description_get_size (fixed_desc);
+				fixed_points = !pango_font_description_get_size_is_absolute (fixed_desc);
 				fixed_family = pango_font_description_get_family (fixed_desc);
 			} else {
 				g_free (fixed_name);
@@ -934,8 +939,8 @@
 
 	html_font_manager_set_default (&painter->font_manager,
 				       (char *)font_var, (char *)fixed_family,
-				       font_var_size, FALSE,
-				       fixed_size, FALSE);
+				       font_var_size, font_var_points,
+				       fixed_size, fixed_points);
 	if (fixed_desc)
 		pango_font_description_free (fixed_desc);
 

Modified: trunk/gtkhtml/htmlpainter.c
==============================================================================
--- trunk/gtkhtml/htmlpainter.c	(original)
+++ trunk/gtkhtml/htmlpainter.c	Wed Apr  8 23:21:19 2009
@@ -833,7 +833,10 @@
 
 	if (face) {
 		desc = pango_font_description_from_string (face);
-		pango_font_description_set_size (desc, (gint) size);
+		if (points)
+			pango_font_description_set_size (desc, (gint) size);
+		else
+			pango_font_description_set_absolute_size (desc, (gint) size);
 	}
 
 	if (!desc || !pango_font_description_get_family (desc)) {
@@ -843,7 +846,11 @@
 		desc = pango_font_description_copy (gtk_widget_get_style (painter->widget)->font_desc);
 	}
 
-	pango_font_description_set_size (desc, size);
+	if (points)
+		pango_font_description_set_size (desc, size);
+	else
+		pango_font_description_set_absolute_size (desc, (gint) size);
+
 	pango_font_description_set_style (desc, style & GTK_HTML_FONT_STYLE_ITALIC ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
 	pango_font_description_set_weight (desc, style & GTK_HTML_FONT_STYLE_BOLD ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
 

Modified: trunk/gtkhtml/testgtkhtml.c
==============================================================================
--- trunk/gtkhtml/testgtkhtml.c	(original)
+++ trunk/gtkhtml/testgtkhtml.c	Wed Apr  8 23:21:19 2009
@@ -315,7 +315,7 @@
 	PangoFontMetrics *metrics;
 	gdouble footer_height;
 
-	desc = pango_font_description_from_string ("Helvetica 12");
+	desc = pango_font_description_from_string ("Helvetica 16px");
 
 	layout = gtk_print_context_create_pango_layout (context);
 	pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);



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