From: Chong Yidong Date: Mon, 19 Jan 2009 16:42:44 +0000 (+0000) Subject: (font_spec_from_name): Return Qnil if font name could not be parsed. X-Git-Tag: emacs-pretest-23.0.90~369 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=05802645c6f249bb377a96c7d75d57d51218ae70;p=emacs.git (font_spec_from_name): Return Qnil if font name could not be parsed. (font_parse_name): Treat a `?' character as part of an XLFD. --- diff --git a/src/font.c b/src/font.c index 178e6d32429..6eb77dc195d 100644 --- a/src/font.c +++ b/src/font.c @@ -1814,7 +1814,7 @@ font_parse_name (name, font) char *name; Lisp_Object font; { - if (name[0] == '-' || index (name, '*')) + if (name[0] == '-' || index (name, '*') || index (name, '?')) return font_parse_xlfd (name, font); return font_parse_fcname (name, font); } @@ -3051,15 +3051,21 @@ font_get_spec (font_object) return spec; } + +/* Create a new font spec from FONT_NAME, and return it. If FONT_NAME + could not be parsed by font_parse_name, return Qnil. */ + Lisp_Object font_spec_from_name (font_name) Lisp_Object font_name; { - Lisp_Object args[2]; + Lisp_Object spec = Ffont_spec (0, NULL); - args[0] = QCname; - args[1] = font_name; - return Ffont_spec (2, args); + CHECK_STRING (font_name); + if (font_parse_name ((char *) SDATA (font_name), spec) == -1) + return Qnil; + font_put_extra (spec, QCname, font_name); + return spec; }