summaryrefslogtreecommitdiff
path: root/src/font.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-12-30 20:28:58 +0200
committerEli Zaretskii <eliz@gnu.org>2021-12-30 20:28:58 +0200
commit89f205084b7368bb2261e07384f8ff1967a70ba4 (patch)
treeee992e95dfb4afcce096a634338b628ab9f68436 /src/font.c
parentf2031d0ddb6a21eebbf396094a5c4d4e73019271 (diff)
downloademacs-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)
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c9
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