From 0f830340afc48461c021b858370004972162837c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 1 Jul 2019 21:12:55 +0300 Subject: [PATCH] More XFIXNUM fixes * src/hbfont.c (hbfont_shape): Don't assume LGLYPH_TO is always a fixnum. * src/fontset.c (fontset_find_font): A cleaner test for matching charset_id. --- src/fontset.c | 34 ++++++++++++++++++---------------- src/hbfont.c | 6 +++++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/fontset.c b/src/fontset.c index 137d2895932..828e7fe70cc 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -564,23 +564,25 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, or the charset priorities were changed. */ reorder_font_vector (font_group, face->ascii_face->font); if (charset_id >= 0) - /* Find a spec matching with CHARSET_ID to try it at - first. */ - for (i = 0; i < ASIZE (vec); i++) - { - Lisp_Object repertory; - - rfont_def = AREF (vec, i); - if (NILP (rfont_def)) - break; - repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); - - if (FIXNUMP (repertory) && XFIXNUM_RAW (repertory) == charset_id) - { - charset_matched = i; + { + Lisp_Object lcsetid = make_fixnum (charset_id); + /* Find a spec matching with CHARSET_ID to try it at first. */ + for (i = 0; i < ASIZE (vec); i++) + { + Lisp_Object repertory; + + rfont_def = AREF (vec, i); + if (NILP (rfont_def)) break; - } - } + repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); + + if (EQ (repertory, lcsetid)) + { + charset_matched = i; + break; + } + } + } } /* Find the first available font in the vector of RFONT-DEF. If diff --git a/src/hbfont.c b/src/hbfont.c index 455c1a7a554..db10f92e313 100644 --- a/src/hbfont.c +++ b/src/hbfont.c @@ -512,9 +512,11 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction) Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); struct font_metrics metrics = {.width = 0}; int xoff, yoff, wadjust; + bool new_lglyph = false; if (NILP (lglyph)) { + new_lglyph = true; lglyph = LGLYPH_NEW (); LGSTRING_SET_GLYPH (lgstring, i, lglyph); } @@ -556,7 +558,9 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction) in the original sequence were processed by the composition. If we don't do this, some of the composed characters will be displayed again as separate glyphs. */ - if (!(to == text_len - 1 && LGLYPH_TO (lglyph) > to)) + if (!(!new_lglyph + && to == text_len - 1 + && LGLYPH_TO (lglyph) > to)) LGLYPH_SET_TO (lglyph, to); /* Not every glyph in a cluster maps directly to a single -- 2.39.2