From 89f205084b7368bb2261e07384f8ff1967a70ba4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 30 Dec 2021 20:28:58 +0200 Subject: [PATCH] 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 . 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 c0050a99cfe..6ff28397d95 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 -- 2.39.2