aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2017-11-30 19:55:41 +0200
committerEli Zaretskii2017-11-30 19:55:41 +0200
commitbdbcdbac431d672915c92fc77dbf7326f338cecb (patch)
tree9893c109d8dbdc0aed12b1cdd4fc27873000a77f
parent408862f02a874dcd9cfc2599adb35dec522b3ef4 (diff)
downloademacs-bdbcdbac431d672915c92fc77dbf7326f338cecb.tar.gz
emacs-bdbcdbac431d672915c92fc77dbf7326f338cecb.zip
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.
-rw-r--r--lisp/composite.el5
-rw-r--r--src/font.c23
2 files changed, 18 insertions, 10 deletions
diff --git a/lisp/composite.el b/lisp/composite.el
index 72b0ffc8f48..f7e0c4a0912 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -337,8 +337,9 @@ When Automatic Composition mode is on, this function also finds a
337chunk of text that is automatically composed. If such a chunk is 337chunk of text that is automatically composed. If such a chunk is
338found closer to POS than the position that has `composition' 338found closer to POS than the position that has `composition'
339property, the value is a list of FROM, TO, and a glyph-string 339property, the value is a list of FROM, TO, and a glyph-string
340that specifies how the chunk is to be composed. See the function 340that specifies how the chunk is to be composed; DETAIL-P is
341`composition-get-gstring' for the format of the glyph-string." 341inored this case. See the function `composition-get-gstring'
342for the format of the glyph-string."
342 (let ((result (find-composition-internal pos limit string detail-p))) 343 (let ((result (find-composition-internal pos limit string detail-p)))
343 (if (and detail-p (> (length result) 3) (nth 2 result) (not (nth 3 result))) 344 (if (and detail-p (> (length result) 3) (nth 2 result) (not (nth 3 result)))
344 ;; This is a valid rule-base composition. 345 ;; This is a valid rule-base composition.
diff --git a/src/font.c b/src/font.c
index f7cebdce78c..441652b0951 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3794,19 +3794,26 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
3794 int c; 3794 int c;
3795 Lisp_Object font_object = Qnil; 3795 Lisp_Object font_object = Qnil;
3796 3796
3797 if (NILP (string)) 3797 if (!face)
3798 { 3798 {
3799 if (! face) 3799 struct frame *f = XFRAME (w->frame);
3800 int face_id;
3801
3802 if (NILP (string))
3803 face_id = face_at_buffer_position (w, pos, &ignore, *limit,
3804 false, -1);
3805 else
3800 { 3806 {
3801 int face_id; 3807 face_id =
3808 NILP (Vface_remapping_alist)
3809 ? DEFAULT_FACE_ID
3810 : lookup_basic_face (f, DEFAULT_FACE_ID);
3802 3811
3803 face_id = face_at_buffer_position (w, pos, &ignore, 3812 face_id = face_at_string_position (w, string, pos, 0, &ignore,
3804 *limit, false, -1); 3813 face_id, false);
3805 face = FACE_FROM_ID (XFRAME (w->frame), face_id);
3806 } 3814 }
3815 face = FACE_FROM_ID (f, face_id);
3807 } 3816 }
3808 else
3809 eassert (face);
3810 3817
3811 while (pos < *limit) 3818 while (pos < *limit)
3812 { 3819 {