changeset 101292:ab308039742a

(Finternal_set_lisp_face_attribute, Fx_list_fonts): Check return value of font_spec_from_name. (Fx_list_fonts): Doc fix.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 19 Jan 2009 16:41:16 +0000
parents 600214d1718d
children 558e0d4ded9a
files src/xfaces.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Mon Jan 19 16:40:30 2009 +0000
+++ b/src/xfaces.c	Mon Jan 19 16:41:16 2009 +0000
@@ -1816,11 +1816,13 @@
        doc: /* Return a list of the names of available fonts matching PATTERN.
 If optional arguments FACE and FRAME are specified, return only fonts
 the same size as FACE on FRAME.
-PATTERN is a string, perhaps with wildcard characters;
+
+PATTERN should be a string containing a font name in the XLFD,
+Fontconfig, or GTK format.  A font name given in the XLFD format may
+contain wildcard characters:
   the * character matches any substring, and
   the ? character matches any single character.
   PATTERN is case-insensitive.
-FACE is a face name--a symbol.
 
 The return value is a list of strings, suitable as arguments to
 `set-face-font'.
@@ -1892,6 +1894,9 @@
     Lisp_Object args[2], tail;
 
     font_spec = font_spec_from_name (pattern);
+    if (!FONTP (font_spec))
+      signal_error ("Invalid font name", pattern);
+
     if (size)
       {
 	Ffont_put (font_spec, QCsize, make_number (size));
@@ -3252,11 +3257,14 @@
 		{
 		  if (STRINGP (value))
 		    {
-		      int fontset = fs_query_fontset (value, 0);
+		      Lisp_Object name = value;
+		      int fontset = fs_query_fontset (name, 0);
 
 		      if (fontset >= 0)
-			value = fontset_ascii (fontset);
-		      value = font_spec_from_name (value);
+			name = fontset_ascii (fontset);
+		      value = font_spec_from_name (name);
+		      if (!FONTP (value))
+			signal_error ("Invalid font name", name);
 		    }
 		  else
 		    signal_error ("Invalid font or font-spec", value);