emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 7d5a7a4: Be more tolerant to fonts named "Foobar-12


From: Eli Zaretskii
Subject: [Emacs-diffs] master 7d5a7a4: Be more tolerant to fonts named "Foobar-12"
Date: Wed, 01 Jul 2015 16:35:03 +0000

branch: master
commit 7d5a7a43f1f6630b269fa7f7dc13e9c80181a709
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Be more tolerant to fonts named "Foobar-12"
    
    * src/frame.c (x_set_font): If font_spec_from_name returns nil,
    don't barf; instead, request a new fontset to be generated.  This
    avoids unnecessarily rejecting fonts named against XLFD rules.  See
    http://lists.gnu.org/archive/html/help-emacs-windows/2015-06/msg00001.html,
    for the description of the original problem.
    
    * lisp/faces.el (set-face-attribute): Don't be fooled too easily
    by a hyphen in a font's name.
---
 lisp/faces.el |   11 +++++++++--
 src/frame.c   |   10 ++++++----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/lisp/faces.el b/lisp/faces.el
index ac6486e..9857a7b 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -753,7 +753,7 @@ is specified, `:italic' is ignored."
   (setq args (purecopy args))
   (let ((where (if (null frame) 0 frame))
        (spec args)
-       family foundry)
+       family foundry orig-family orig-foundry)
     ;; If we set the new-frame defaults, this face is modified outside Custom.
     (if (memq where '(0 t))
        (put (or (get face 'face-alias) face) 'face-modified t))
@@ -769,9 +769,16 @@ is specified, `:italic' is ignored."
     (when (or family foundry)
       (when (and (stringp family)
                 (string-match "\\([^-]*\\)-\\([^-]*\\)" family))
+        (setq orig-foundry foundry
+              orig-family family)
        (unless foundry
          (setq foundry (match-string 1 family)))
-       (setq family (match-string 2 family)))
+       (setq family (match-string 2 family))
+        ;; Reject bogus "families" that are all-digits -- those are some
+        ;; weird font names, like Foobar-12, that end in a number.
+        (when (string-match "\\`[0-9]*\\'" family)
+          (setq family orig-family)
+          (setq foundry orig-foundry)))
       (when (or (stringp family) (eq family 'unspecified))
        (internal-set-lisp-face-attribute face :family (purecopy family)
                                          where))
diff --git a/src/frame.c b/src/frame.c
index e3ad82f..9e69598 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3607,10 +3607,12 @@ x_set_font (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
          Lisp_Object ascii_font = fontset_ascii (fontset);
          Lisp_Object spec = font_spec_from_name (ascii_font);
 
-         if (NILP (spec))
-           signal_error ("Invalid font name", ascii_font);
-
-         if (! font_match_p (spec, font_object))
+         /* SPEC might be nil because ASCII_FONT's name doesn't parse
+            according to stupid XLFD rules, which, for example,
+            disallow font names that include a dash followed by a
+            number.  So in those cases we simply request x_new_font
+            below to generate a new fontset.  */
+         if (NILP (spec) || ! font_match_p (spec, font_object))
            fontset = -1;
        }
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]