-(defun decompose-string (string)
- "Decompose all composite characters in STRING."
- (let* ((l (string-to-list string))
- (tail l)
- ch)
- (while tail
- (setq ch (car tail))
- (setcar tail (if (cmpcharp ch) (decompose-composite-char ch)
- (char-to-string ch)))
- (setq tail (cdr tail)))
- (apply 'concat l)))
-
-;;;###autoload
-(defconst reference-point-alist
- '((tl . 0) (tc . 1) (tr . 2)
- (ml . 3) (mc . 4) (mr . 5)
- (bl . 6) (bc . 7) (br . 8)
- (top-left . 0) (top-center . 1) (top-right . 2)
- (mid-left . 3) (mid-center . 4) (mid-right . 5)
- (bottom-left . 6) (bottom-center . 7) (bottom-right . 8)
- (0 . 0) (1 . 1) (2 . 2)
- (3 . 3) (4 . 4) (5 . 5)
- (6 . 6) (7 . 7) (8 . 8))
- "Alist of reference point symbols vs reference point codes.
-A reference point symbol is to be used to specify a composition rule
-while making a composite character by the function `compose-chars'
-(which see).
-
-Meanings of reference point codes are as follows:
-
- 0----1----2 <-- ascent 0:tl or top-left
- | | 1:tc or top-center
- | | 2:tr or top-right
- | | 3:ml or mid-left
- | 4 <--+---- center 4:mc or mid-center
- | | 5:mr or mid-right
---- 3 5 <-- baseline 6:bl or bottom-left
- | | 7:bc or bottom-center
- 6----7----8 <-- descent 8:br or bottom-right
-
-Reference point symbols are to be used to specify composition rule of
-the form \(GLOBAL-REF-POINT . NEW-REF-POINT), where GLOBAL-REF-POINT
-is a reference point in the overall glyphs already composed, and
-NEW-REF-POINT is a reference point in the new glyph to be added.
-
-For instance, if GLOBAL-REF-POINT is 8 and NEW-REF-POINT is 1, the
-overall glyph is updated as follows:
-
- +-------+--+ <--- new ascent
- | | |
- | global| |
- | glyph | |
---- | | | <--- baseline (doesn't change)
- +----+--+--+
- | | new |
- | |glyph|
- +----+-----+ <--- new descent
-")
-
-;; Return a string for char CH to be embedded in multibyte form of
-;; composite character.
-(defun compose-chars-component (ch)
- (if (< ch 128)
- (format "\240%c" (+ ch 128))
- (let ((str (char-to-string ch)))
- (if (cmpcharp ch)
- (substring str (if (= (aref str 1) ?\xFF) 2 1))
- (aset str 0 (+ (aref str 0) ?\x20))
- str))))
-
-;; Return a string for composition rule RULE to be embedded in
-;; multibyte form of composite character.
-(defsubst compose-chars-rule (rule)
- (char-to-string (+ ?\xA0
- (* (cdr (assq (car rule) reference-point-alist)) 9)
- (cdr (assq (cdr rule) reference-point-alist)))))
-
-;;;###autoload
-(defun compose-chars (first-component &rest args)
- "Return one char string composed from the arguments.
-Each argument is a character (including a composite chararacter)
-or a composition rule.
-A composition rule has the form \(GLOBAL-REF-POINT . NEW-REF-POINT).
-See the documentation of `reference-point-alist' for more detail."
- (if (= (length args) 0)
- (char-to-string first-component)
- (let* ((with-rule (consp (car args)))
- (str (if with-rule (concat (vector leading-code-composition ?\xFF))
- (char-to-string leading-code-composition))))
- (setq str (concat str (compose-chars-component first-component)))
- (while args
- (if with-rule
- (progn
- (if (not (consp (car args)))
- (error "Invalid composition rule: %s" (car args)))
- (setq str (concat str (compose-chars-rule (car args))
- (compose-chars-component (car (cdr args))))
- args (cdr (cdr args))))
- (setq str (concat str (compose-chars-component (car args)))
- args (cdr args))))
- str)))
+(defun char-displayable-p (char)
+ "Return non-nil if we should be able to display CHAR.
+On a multi-font display, the test is only whether there is an
+appropriate font from the selected frame's fontset to display CHAR's
+charset in general. Since fonts may be specified on a per-character
+basis, this may not be accurate."
+ (cond ((< char 256)
+ ;; Single byte characters are always displayable.
+ t)
+ ((display-multi-font-p)
+ ;; On a window system, a character is displayable if we have
+ ;; a font for that character in the default face of the
+ ;; currently selected frame.
+ (car (internal-char-font nil char)))
+ (t
+ (let ((coding (terminal-coding-system)))
+ (if coding
+ (let ((safe-chars (coding-system-get coding 'safe-chars))
+ (safe-charsets (coding-system-get coding 'safe-charsets)))
+ (or (and safe-chars
+ (aref safe-chars char))
+ (and safe-charsets
+ (memq (char-charset char) safe-charsets)))))))))
+\f
+(provide 'mule-util)