Function: auto-compose-chars

auto-compose-chars is a byte-compiled function defined in composite.el.gz.

Signature

(auto-compose-chars FUNC FROM TO FONT-OBJECT STRING DIRECTION)

Documentation

Compose the characters at FROM by FUNC.

FUNC is called with two arguments: GSTRING, which is built for characters in the region FROM (inclusive) and TO (exclusive); and DIRECTION, which is the bidi directionality of the characters.

If the character are composed on a graphic display, FONT-OBJECT is a font to use. Otherwise, FONT-OBJECT is nil, and the function compose-gstring-for-terminal is used instead of FUNC.

If STRING is non-nil, it is a string, and FROM and TO are indices into the string. In that case, compose characters in the string.

The value is a gstring containing information for shaping the characters.

This function is the default value of auto-composition-function (which see).

Probably introduced at or before Emacs version 23.1.

Source Code

;; Defined in /usr/src/emacs/lisp/composite.el.gz
(defun auto-compose-chars (func from to font-object string direction)
  "Compose the characters at FROM by FUNC.
FUNC is called with two arguments: GSTRING, which is built for
characters in the region FROM (inclusive) and TO (exclusive);
and DIRECTION, which is the bidi directionality of the characters.

If the character are composed on a graphic display, FONT-OBJECT
is a font to use.  Otherwise, FONT-OBJECT is nil, and the function
`compose-gstring-for-terminal' is used instead of FUNC.

If STRING is non-nil, it is a string, and FROM and TO are indices
into the string.  In that case, compose characters in the string.

The value is a gstring containing information for shaping the characters.

This function is the default value of `auto-composition-function' (which see)."
  (let ((gstring (composition-get-gstring from to font-object string)))
    (cond
     ((lgstring-shaped-p gstring)
      gstring)
     ;; The graphical composition function already handles the
     ;; composition of Emoji sequences based on the font.  On textual
     ;; terminals, we compose Emoji sequences and leave the actual
     ;; rendering to the terminal emulator.
     ((and (eq func #'compose-gstring-and-emoji)
           (fontp font-object 'font-object))
      (compose-gstring-for-graphic gstring direction))
     ((eq func #'compose-gstring-and-emoji)
      (compose-gstring-and-emoji-for-terminal gstring direction))
     ((fontp font-object 'font-object)
      (funcall func gstring direction))
     (t
      (compose-gstring-for-terminal gstring direction)))))