changeset 91353:b93ade1a3602

(font_find_for_lface): Check if the character C is supported or not only for the first font.
author Kenichi Handa <handa@m17n.org>
date Mon, 28 Jan 2008 07:05:07 +0000
parents b6befec471b8
children 99ac532a6a03
files src/font.c
diffstat 1 files changed, 20 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/font.c	Mon Jan 28 07:03:27 2008 +0000
+++ b/src/font.c	Mon Jan 28 07:05:07 2008 +0000
@@ -2603,8 +2603,8 @@
      Lisp_Object spec;
      int c;
 {
-  Lisp_Object frame, entities;
-  int i;
+  Lisp_Object frame, entities, val;
+  int i, result;
 
   XSETFRAME (frame, f);
 
@@ -2646,9 +2646,9 @@
 
       if (c >= 0)
 	{
-	  struct charset *repertory;
-
-	  if (font_registry_charsets (registry, NULL, &repertory) < 0)
+	  struct charset *encoding, *repertory;
+
+	  if (font_registry_charsets (registry, &encoding, &repertory) < 0)
 	    return Qnil;
 	  if (repertory)
 	    {
@@ -2659,7 +2659,7 @@
 		 suppress the further checking.  */
 	      c = -1;
 	    }
-	  else if (c > MAX_UNICODE_CHAR)
+	  else if (c > encoding->max_char)
 	    return Qnil;
 	}
       for (i = 0; i < FONT_SPEC_MAX; i++)
@@ -2692,23 +2692,19 @@
 
   if (c < 0)
     return AREF (entities, 0);
-  for (i = 0; i < ASIZE (entities); i++)
-    {
-      int result = font_has_char (f, AREF (entities, i), c);
-      Lisp_Object font_object;
-
-      if (result > 0)
-	return AREF (entities, i);
-      if (result == 0)
-	continue;
-      font_object = font_open_for_lface (f, AREF (entities, i), lface, spec);
-      if (NILP (font_object))
-	continue;
-      result = font_has_char (f, font_object, c);
-      font_close_object (f, font_object);
-      if (result > 0)
-	return AREF (entities, i);
-    }      
+
+  val = AREF (entities, 0);
+  result = font_has_char (f, val, c);
+  if (result > 0)
+    return val;
+  if (result == 0)
+    return Qnil;
+  val = font_open_for_lface (f, val, lface, spec);
+  if (NILP (val))
+    return Qnil;
+  result = font_has_char (f, val, c);
+  if (result > 0)
+    return val;
   return Qnil;
 }
 
@@ -3101,7 +3097,7 @@
 /* Lisp API */
 
 DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0,
-       doc: /* Return t if OBJECT is a font-spec or font-entity.
+       doc: /* Return t if OBJECT is a font-spec, font-entity, or font-object.
 Return nil otherwise.  */)
      (object)
      Lisp_Object object;