Commit 8da43785 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(compose-gstring-for-terminal): If a character is

not supported by the current terminal, don't make a multi-glyph
grapheme cluster.
(auto-compose-chars): Check font-object by fontp.
parent 4cb75c4b
...@@ -664,28 +664,45 @@ a prepending a space before it." ...@@ -664,28 +664,45 @@ a prepending a space before it."
(nchars (lgstring-char-len gstring)) (nchars (lgstring-char-len gstring))
(nglyphs (lgstring-glyph-len gstring)) (nglyphs (lgstring-glyph-len gstring))
(i 0) (i 0)
(coding (lgstring-font gstring))
glyph) glyph)
(while (and (< i nglyphs) (while (and (< i nglyphs)
(setq glyph (lgstring-glyph gstring i))) (setq glyph (lgstring-glyph gstring i)))
(if (= (lglyph-width glyph) 0) (if (not (char-charset (lglyph-char glyph) coding))
(progn (progn
;; Compose by prepending a space. ;; As the terminal doesn't support this glyph, return a
(setq gstring (lgstring-insert-glyph gstring i (lglyph-copy glyph)) ;; gstring in which each glyph is its own graphme-cluster
nglyphs (lgstring-glyph-len gstring)) ;; of width 1..
(lglyph-set-char (lgstring-glyph gstring i) 32) (setq i 0)
(setq i (+ 2))) (while (and (< i nglyphs)
(let ((from (lglyph-from glyph)) (setq glyph (lgstring-glyph gstring i)))
(to (lglyph-to glyph)) (if (< (lglyph-width glyph) 1)
(j (1+ i))) (lglyph-set-width glyph 1))
(while (and (< j nglyphs) (lglyph-set-from-to glyph i i)
(setq glyph (lgstring-glyph gstring j)) (setq i (1+ i))))
(= (lglyph-width glyph) 0)) (if (= (lglyph-width glyph) 0)
(setq to (lglyph-to glyph) (progn
j (1+ j))) ;; Compose by prepending a space.
(while (< i j) (setq gstring (lgstring-insert-glyph gstring i
(setq glyph (lgstring-glyph gstring i)) (lglyph-copy glyph))
(lglyph-set-from-to glyph from to) nglyphs (lgstring-glyph-len gstring))
(setq i (1+ i)))))) (setq glyph (lgstring-glyph gstring i))
(lglyph-set-char glyph 32)
(lglyph-set-width glyph 1)
(setq i (+ 2)))
(let ((from (lglyph-from glyph))
(to (lglyph-to glyph))
(j (1+ i)))
(while (and (< j nglyphs)
(setq glyph (lgstring-glyph gstring j))
(char-charset (lglyph-char glyph) coding)
(= (lglyph-width glyph) 0))
(setq to (lglyph-to glyph)
j (1+ j)))
(while (< i j)
(setq glyph (lgstring-glyph gstring i))
(lglyph-set-from-to glyph from to)
(setq i (1+ i)))))))
gstring)) gstring))
...@@ -709,7 +726,7 @@ This function is the default value of `auto-composition-function' (which see)." ...@@ -709,7 +726,7 @@ This function is the default value of `auto-composition-function' (which see)."
(let ((gstring (composition-get-gstring from to font-object string))) (let ((gstring (composition-get-gstring from to font-object string)))
(if (lgstring-shaped-p gstring) (if (lgstring-shaped-p gstring)
gstring gstring
(or font-object (or (fontp font-object 'font-object)
(setq func 'compose-gstring-for-terminal)) (setq func 'compose-gstring-for-terminal))
(funcall func gstring)))) (funcall func gstring))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment