diff options
| author | Eli Zaretskii | 2023-08-12 09:38:28 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-08-12 09:38:28 +0300 |
| commit | 03e897c08facf8e920ee04cd505b72f5aa5a30cf (patch) | |
| tree | 87221aa14947ab45d7d1c9664c7fb5e8812776ef /src | |
| parent | b1ba06a1e4bac45cecddeb961ec3e56afa390c3f (diff) | |
| download | emacs-03e897c08facf8e920ee04cd505b72f5aa5a30cf.tar.gz emacs-03e897c08facf8e920ee04cd505b72f5aa5a30cf.zip | |
Fix rare crashes in redisplay due to problems with fontsets
* src/xdisp.c (get_next_display_element): If we have no usable
face to display a character/composition, treat that as glyphless.
(produce_glyphless_glyph): If neither it->face nor its ASCII face
are usable, fall back to the frame's default font. (Bug#65198)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 9cddcfeda27..22508978298 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -8312,9 +8312,17 @@ get_next_display_element (struct it *it) | |||
| 8312 | && success_p | 8312 | && success_p |
| 8313 | && FRAME_WINDOW_P (it->f)) | 8313 | && FRAME_WINDOW_P (it->f)) |
| 8314 | { | 8314 | { |
| 8315 | struct face *face = FACE_FROM_ID (it->f, it->face_id); | 8315 | struct face *face = FACE_FROM_ID_OR_NULL (it->f, it->face_id); |
| 8316 | 8316 | ||
| 8317 | if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0) | 8317 | /* It shouldn't happen, ever, that FACE is NULL here, but |
| 8318 | evidently some faulty fonts/fontsets can sometimes cause it. | ||
| 8319 | In that case, we punt and consider the stuff undisplayable. */ | ||
| 8320 | if (!face) | ||
| 8321 | { | ||
| 8322 | it->what = IT_GLYPHLESS; | ||
| 8323 | it->glyphless_method = GLYPHLESS_DISPLAY_EMPTY_BOX; | ||
| 8324 | } | ||
| 8325 | else if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0) | ||
| 8318 | { | 8326 | { |
| 8319 | /* Automatic composition with glyph-string. */ | 8327 | /* Automatic composition with glyph-string. */ |
| 8320 | Lisp_Object gstring = composition_gstring_from_id (it->cmp_it.id); | 8328 | Lisp_Object gstring = composition_gstring_from_id (it->cmp_it.id); |
| @@ -31781,9 +31789,12 @@ produce_glyphless_glyph (struct it *it, bool for_no_font, Lisp_Object acronym) | |||
| 31781 | int len; | 31789 | int len; |
| 31782 | 31790 | ||
| 31783 | /* Get the metrics of the base font. We always refer to the current | 31791 | /* Get the metrics of the base font. We always refer to the current |
| 31784 | ASCII face. */ | 31792 | ASCII face, but if some faulty setup of fontsets causes that to |
| 31785 | face = FACE_FROM_ID (it->f, it->face_id)->ascii_face; | 31793 | be NULL, we fall back to the frame's default font. */ |
| 31786 | font = face->font ? face->font : FRAME_FONT (it->f); | 31794 | face = FACE_FROM_ID_OR_NULL (it->f, it->face_id); |
| 31795 | if (face) | ||
| 31796 | face = face->ascii_face; | ||
| 31797 | font = (face && face->font) ? face->font : FRAME_FONT (it->f); | ||
| 31787 | normal_char_ascent_descent (font, -1, &it->ascent, &it->descent); | 31798 | normal_char_ascent_descent (font, -1, &it->ascent, &it->descent); |
| 31788 | it->ascent += font->baseline_offset; | 31799 | it->ascent += font->baseline_offset; |
| 31789 | it->descent -= font->baseline_offset; | 31800 | it->descent -= font->baseline_offset; |