Skip to content

Commit

Permalink
Avoid assertion violations with variable-weight fonts
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
Eli-Zaretskii committed Dec 30, 2021
1 parent f2031d0 commit 89f2050
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/font.c
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 89f2050

Please sign in to comment.