-static enum prop_handled
-handle_auto_composed_prop (it)
- struct it *it;
-{
- enum prop_handled handled = HANDLED_NORMALLY;
-
- if (FRAME_WINDOW_P (it->f) && FUNCTIONP (Vauto_composition_function))
- {
- Lisp_Object val = Qnil;
- EMACS_INT pos, limit = -1;
-
- if (STRINGP (it->string))
- pos = IT_STRING_CHARPOS (*it);
- else
- pos = IT_CHARPOS (*it);
-
- val = Fget_text_property (make_number (pos), Qauto_composed, it->string);
- if (! NILP (val))
- {
- Lisp_Object cmp_prop;
- EMACS_INT cmp_start, cmp_end;
-
- if (get_property_and_range (pos, Qcomposition, &cmp_prop,
- &cmp_start, &cmp_end, it->string)
- && cmp_start == pos
- && COMPOSITION_METHOD (cmp_prop) == COMPOSITION_WITH_GLYPH_STRING)
- {
- Lisp_Object gstring = COMPOSITION_COMPONENTS (cmp_prop);
- Lisp_Object font_object = LGSTRING_FONT (gstring);
-
- if (! EQ (font_object,
- font_at (-1, pos, FACE_FROM_ID (it->f, it->face_id),
- it->w, it->string)))
- /* We must re-compute the composition for the
- different font. */
- val = Qnil;
- }
-
- if (! NILP (val))
- {
- Lisp_Object end;
-
- /* As Fnext_single_char_property_change is very slow, we
- limit the search to the current line. */
- if (STRINGP (it->string))
- limit = SCHARS (it->string);
- else
- limit = find_next_newline_no_quit (pos, 1);
- end = Fnext_single_char_property_change (make_number (pos),
- Qauto_composed,
- it->string,
- make_number (limit));
-
- if (XINT (end) < limit)
- /* The current point is auto-composed, but there exist
- characters not yet composed beyond the
- auto-composed region. There's a possiblity that
- the last characters in the region may be newly
- composed. */
- val = Qnil;
- }
- }
- if (NILP (val) && ! STRINGP (it->string))
- {
- if (limit < 0)
- limit = (STRINGP (it->string) ? SCHARS (it->string)
- : find_next_newline_no_quit (pos, 1));
- if (pos < limit)
- {
- int count = SPECPDL_INDEX ();
- Lisp_Object args[5];
-
- limit = font_range (pos, limit, FACE_FROM_ID (it->f, it->face_id),
- it->f, it->string);
- args[0] = Vauto_composition_function;
- specbind (Qauto_composition_function, Qnil);
- args[1] = make_number (pos);
- args[2] = make_number (limit);
- args[3] = it->window;
- args[4] = it->string;
- safe_call (5, args);
- unbind_to (count, Qnil);
- }
- }
- }
-
- return handled;
-}
-