Avoid assertions in find-composition

* src/font.c (font_range): If called with STRING non-nil and FACE
a NULL pointer, compute face by calling face_at_string_position.
(Bug#29506)

* lisp/composite.el (find-composition): Doc fix.
This commit is contained in:
Eli Zaretskii 2017-11-30 19:55:41 +02:00
parent 408862f02a
commit bdbcdbac43
2 changed files with 19 additions and 11 deletions

View file

@ -337,8 +337,9 @@ When Automatic Composition mode is on, this function also finds a
chunk of text that is automatically composed. If such a chunk is chunk of text that is automatically composed. If such a chunk is
found closer to POS than the position that has `composition' found closer to POS than the position that has `composition'
property, the value is a list of FROM, TO, and a glyph-string property, the value is a list of FROM, TO, and a glyph-string
that specifies how the chunk is to be composed. See the function that specifies how the chunk is to be composed; DETAIL-P is
`composition-get-gstring' for the format of the glyph-string." inored this case. See the function `composition-get-gstring'
for the format of the glyph-string."
(let ((result (find-composition-internal pos limit string detail-p))) (let ((result (find-composition-internal pos limit string detail-p)))
(if (and detail-p (> (length result) 3) (nth 2 result) (not (nth 3 result))) (if (and detail-p (> (length result) 3) (nth 2 result) (not (nth 3 result)))
;; This is a valid rule-base composition. ;; This is a valid rule-base composition.

View file

@ -3794,19 +3794,26 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
int c; int c;
Lisp_Object font_object = Qnil; Lisp_Object font_object = Qnil;
if (NILP (string)) if (!face)
{ {
if (! face) struct frame *f = XFRAME (w->frame);
{ int face_id;
int face_id;
face_id = face_at_buffer_position (w, pos, &ignore, if (NILP (string))
*limit, false, -1); face_id = face_at_buffer_position (w, pos, &ignore, *limit,
face = FACE_FROM_ID (XFRAME (w->frame), face_id); false, -1);
else
{
face_id =
NILP (Vface_remapping_alist)
? DEFAULT_FACE_ID
: lookup_basic_face (f, DEFAULT_FACE_ID);
face_id = face_at_string_position (w, string, pos, 0, &ignore,
face_id, false);
} }
face = FACE_FROM_ID (f, face_id);
} }
else
eassert (face);
while (pos < *limit) while (pos < *limit)
{ {