sawfish r4222 - trunk/src



Author: jkozicki
Date: Mon Feb 18 19:21:23 2008
New Revision: 4222
URL: http://svn.gnome.org/viewvc/sawfish?rev=4222&view=rev

Log:
patch by Yuuki Harano and Rodrigo Gallardo, "Pango draw() ignores font"

allows using pango fonts correctly.



Modified:
   trunk/src/fonts.c

Modified: trunk/src/fonts.c
==============================================================================
--- trunk/src/fonts.c	(original)
+++ trunk/src/fonts.c	Mon Feb 18 19:21:23 2008
@@ -459,24 +459,29 @@
     pango_context_set_font_description (pango_context, fontdesc);
     font = pango_context_load_font (pango_context, fontdesc);
 
-    if (!font)
+    if (!font) {
+        pango_font_description_free(fontdesc);
 	return FALSE;
+    }
 
     metrics = pango_font_get_metrics (font, language);
 
-    f->font = font;
     f->ascent = metrics->ascent / PANGO_SCALE;
     f->descent = metrics->descent / PANGO_SCALE;
 
     pango_font_metrics_unref (metrics);
 
+    f->font = fontdesc; // We save the font description, not the font itself!
+                        // That's because it seems we can't recover it perfectly
+                        // later, and the layout routines want a description
+
     return TRUE;
 }
 
 static void
 pango_finalize (Lisp_Font *f)
 {
-    g_object_unref (f->font);
+    pango_font_description_free (f->font);
 }
 
 static int
@@ -486,6 +491,7 @@
     PangoRectangle rect;
 
     layout = pango_layout_new (pango_context);
+    pango_layout_set_font_description(layout, f->font);
     pango_layout_set_text (layout, string, length);
 
     pango_layout_get_extents (layout, NULL, &rect);
@@ -541,6 +547,7 @@
     xft_color.color.alpha = fg->alpha;
 
     layout = pango_layout_new (pango_context);
+    pango_layout_set_font_description(layout, f->font);
     pango_layout_set_text (layout, string, length);
     iter = pango_layout_get_iter (layout);
 



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