emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 89f205084b: Avoid assertion violations with variable-weight fon


From: Eli Zaretskii
Subject: emacs-28 89f205084b: Avoid assertion violations with variable-weight fonts
Date: Thu, 30 Dec 2021 13:30:49 -0500 (EST)

branch: emacs-28
commit 89f205084b7368bb2261e07384f8ff1967a70ba4
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid assertion violations with variable-weight fonts
    
    * src/font.c (font_score, font_delete_unmatched): Don't assume
    weight, slant, and width properties of the font must be fixnums:
    some variable-weight fonts violate that assumption.  Reported
    by Sean Whitton <spwhitton@spwhitton.name>.  Do not merge to
    master.  (Bug#52888)
---
 src/font.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/font.c b/src/font.c
index c0050a99cf..6ff28397d9 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2170,7 +2170,9 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop)
 
   /* Score three style numeric fields.  Maximum difference is 127. */
   for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++)
-    if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]))
+    if (! NILP (spec_prop[i])
+       && ! EQ (AREF (entity, i), spec_prop[i])
+       && FIXNUMP (AREF (entity, i)))
       {
        EMACS_INT diff = ((XFIXNUM (AREF (entity, i)) >> 8)
                          - (XFIXNUM (spec_prop[i]) >> 8));
@@ -2749,8 +2751,9 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, 
int size)
        }
       for (prop = FONT_WEIGHT_INDEX; prop < FONT_SIZE_INDEX; prop++)
        if (FIXNUMP (AREF (spec, prop))
-           && ((XFIXNUM (AREF (spec, prop)) >> 8)
-               != (XFIXNUM (AREF (entity, prop)) >> 8)))
+           && ! (FIXNUMP (AREF (entity, prop))
+                 && ((XFIXNUM (AREF (spec, prop)) >> 8)
+                     == (XFIXNUM (AREF (entity, prop)) >> 8))))
          prop = FONT_SPEC_MAX;
       if (prop < FONT_SPEC_MAX
          && size



reply via email to

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