diff options
author | Eli Zaretskii <eliz@gnu.org> | 2021-12-30 20:28:58 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2021-12-30 20:28:58 +0200 |
commit | 89f205084b7368bb2261e07384f8ff1967a70ba4 (patch) | |
tree | ee992e95dfb4afcce096a634338b628ab9f68436 | |
parent | f2031d0ddb6a21eebbf396094a5c4d4e73019271 (diff) | |
download | emacs-89f205084b7368bb2261e07384f8ff1967a70ba4.tar.gz |
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)
-rw-r--r-- | src/font.c | 9 |
1 files 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 |