diff src/glyphs.c @ 4815:6540302eedf5

Fix query_string_geometry lookup domain
author Didier Verna <didier@lrde.epita.fr>
date Sat, 09 Jan 2010 15:31:25 +0100
parents 8f1ee2d15784
children 576f09d387d5
line wrap: on
line diff
--- a/src/glyphs.c	Fri Jan 08 14:30:22 2010 +0000
+++ b/src/glyphs.c	Sat Jan 09 15:31:25 2010 +0100
@@ -2379,9 +2379,10 @@
 {
   struct font_metric_info fm;
   unsigned char charsets[NUM_LEADING_BYTES];
-  struct face_cachel frame_cachel;
-  struct face_cachel *cachel;
-  Lisp_Object frame = DOMAIN_FRAME (domain);
+  struct face_cachel cachel;
+  struct face_cachel *the_cachel;
+  Lisp_Object window = DOMAIN_WINDOW (domain);
+  Lisp_Object frame  = DOMAIN_FRAME  (domain);
 
   CHECK_STRING (string);
 
@@ -2396,18 +2397,22 @@
       /* Fallback to the default face if none was provided. */
       if (!NILP (face))
 	{
-	  reset_face_cachel (&frame_cachel);
-	  update_face_cachel_data (&frame_cachel, frame, face);
-	  cachel = &frame_cachel;
+	  reset_face_cachel (&cachel);
+	  update_face_cachel_data (&cachel,
+				   /* #### NOTE: in fact, I'm not sure if it's
+				      #### possible to *not* get a window
+				      #### here, but you never know...
+				      #### -- dvl */
+				   NILP (window) ? frame : window,
+				   face);
+	  the_cachel = &cachel;
 	}
       else
-	{
-	  cachel = WINDOW_FACE_CACHEL (DOMAIN_XWINDOW (domain),
-				       DEFAULT_INDEX);
-	}
-
-      ensure_face_cachel_complete (cachel, domain, charsets);
-      face_cachel_charset_font_metric_info (cachel, charsets, &fm);
+	the_cachel = WINDOW_FACE_CACHEL (DOMAIN_XWINDOW (domain),
+					 DEFAULT_INDEX);
+
+      ensure_face_cachel_complete (the_cachel, domain, charsets);
+      face_cachel_charset_font_metric_info (the_cachel, charsets, &fm);
 
       *height = fm.ascent + fm.descent;
       /* #### descent only gets set if we query the height as well. */
@@ -2417,16 +2422,9 @@
 
   /* Compute width */
   if (width)
-    {
-      if (!NILP (face))
-	*width = redisplay_frame_text_width_string (XFRAME (frame),
-						    face,
-						    0, string, 0, -1);
-      else
-	*width = redisplay_frame_text_width_string (XFRAME (frame),
-						    Vdefault_face,
-						    0, string, 0, -1);
-    }
+    *width = redisplay_text_width_string (domain,
+					  NILP (face) ? Vdefault_face : face,
+					  0, string, 0, -1);
 }
 
 Lisp_Object