summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2018-12-29 16:35:09 +0200
committerEli Zaretskii <eliz@gnu.org>2018-12-29 16:35:09 +0200
commit48776b70115edf3775df19d80f734048dadff198 (patch)
tree10a7e72a45bbbdf8dbfed4afce59fc9a5b975110 /lisp
parent1a80b5d9b8cfa0e523b596db5d1e7e6074dbee46 (diff)
downloademacs-48776b70115edf3775df19d80f734048dadff198.tar.gz
Provide text directionality and language to HarfBuzz shaper
* lisp/language/tv-util.el (tai-viet-composition-function): * lisp/language/ethio-util.el (ethio-composition-function): * lisp/language/japanese.el (compose-gstring-for-variation-glyph): * lisp/language/thai-util.el (thai-composition-function): * lisp/language/misc-lang.el (arabic-shape-gstring): * lisp/language/lao-util.el (lao-composition-function): * lisp/language/hebrew.el (hebrew-shape-gstring): * lisp/composite.el (compose-gstring-for-graphic) (compose-gstring-for-dotted-circle, auto-compose-chars) (compose-gstring-for-terminal): Accept 2nd argument DIRECTION; all callers changed. * src/composite.c (composition_reseat_it): Call auto-composition-function with one more argument DIRECTION. (syms_of_composite) <auto-composition-function>: Update the doc string. * src/ftfont.c (ftfont_shape_by_hb): Compute language and direction, and set buffer properties accordingly. * src/composite.c (autocmp_chars): * src/w32uniscribe.c (uniscribe_shape): * src/xftfont.c (xftfont_shape): * src/ftfont.c (ftfont_shape, ftfont_shape_by_hb): * src/font.c (Ffont_shape_gstring): Accept an additional argument DIRECTION. * src/macfont.m (lgstring_direction): New enum. (mac_font_shape_1, mac_screen_font_shape, mac_font_shape): Accept an additional argument specifying text direction. All callers changed. * src/font.c (syms_of_font): New symbols QL2R and QR2L. * src/font.h (shape): Accept new argument DIRECTION. All implementations changed. (Bug#33729) (ftfont_shape): Update prototype.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/composite.el26
-rw-r--r--lisp/language/ethio-util.el2
-rw-r--r--lisp/language/hebrew.el6
-rw-r--r--lisp/language/ind-util.el3
-rw-r--r--lisp/language/japanese.el2
-rw-r--r--lisp/language/lao-util.el6
-rw-r--r--lisp/language/misc-lang.el4
-rw-r--r--lisp/language/thai-util.el6
-rw-r--r--lisp/language/tv-util.el2
9 files changed, 31 insertions, 26 deletions
diff --git a/lisp/composite.el b/lisp/composite.el
index 3d4805e8fa0..6d280c84d78 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -382,8 +382,8 @@ This function is the default value of `compose-chars-after-function'."
(looking-at pattern))
(<= (match-end 0) limit))
(setq result
- (funcall func pos (match-end 0) font-obj object)))
- (setq result (funcall func pos limit font-obj object)))
+ (funcall func pos (match-end 0) font-obj object nil)))
+ (setq result (funcall func pos limit font-obj object nil)))
(if result (setq tail nil))))))
result))
@@ -524,8 +524,9 @@ after a sequence of character events."
(setq from (1+ from)))
gstring))
-(defun compose-gstring-for-graphic (gstring)
- "Compose glyph-string GSTRING for graphic display.
+(defun compose-gstring-for-graphic (gstring direction)
+ "Compose glyph-string GSTRING under bidi DIRECTION for graphic display.
+DIRECTION is either L2R or R2L, or nil if unknown.
Combining characters are composed with the preceding base
character. If the preceding character is not a base character,
each combining character is composed as a spacing character by
@@ -559,7 +560,7 @@ All non-spacing characters have this function in
;; A base character and the following non-spacing characters.
(t
- (let ((gstr (font-shape-gstring gstring)))
+ (let ((gstr (font-shape-gstring gstring direction)))
(if (and gstr
(> (lglyph-to (lgstring-glyph gstr 0)) 0))
gstr
@@ -686,12 +687,12 @@ All non-spacing characters have this function in
(setq i (1+ i))))
gstring))))))
-(defun compose-gstring-for-dotted-circle (gstring)
+(defun compose-gstring-for-dotted-circle (gstring direction)
(let* ((dc (lgstring-glyph gstring 0)) ; glyph of dotted-circle
(dc-id (lglyph-code dc))
(fc (lgstring-glyph gstring 1)) ; glyph of the following char
(fc-id (lglyph-code fc))
- (gstr (and nil (font-shape-gstring gstring))))
+ (gstr (and nil (font-shape-gstring gstring direction))))
(if (and gstr
(or (= (lgstring-glyph-len gstr) 1)
(and (= (lgstring-glyph-len gstr) 2)
@@ -742,7 +743,7 @@ All non-spacing characters have this function in
(aset composition-function-table #x25CC
`([,(purecopy ".\\c^") 0 compose-gstring-for-dotted-circle])))
-(defun compose-gstring-for-terminal (gstring)
+(defun compose-gstring-for-terminal (gstring _direction)
"Compose glyph-string GSTRING for terminal display.
Non-spacing characters are composed with the preceding base
character. If the preceding character is not a base character,
@@ -799,10 +800,11 @@ prepending a space before it."
gstring))
-(defun auto-compose-chars (func from to font-object string)
+(defun auto-compose-chars (func from to font-object string direction)
"Compose the characters at FROM by FUNC.
-FUNC is called with one argument GSTRING which is built for characters
-in the region FROM (inclusive) and TO (exclusive).
+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
@@ -819,7 +821,7 @@ This function is the default value of `auto-composition-function' (which see)."
gstring
(or (fontp font-object 'font-object)
(setq func 'compose-gstring-for-terminal))
- (funcall func gstring))))
+ (funcall func gstring direction))))
(put 'auto-composition-mode 'permanent-local t)
diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index 1ea01684eaa..0729a6d3a63 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -1014,7 +1014,7 @@ With ARG, insert that many delimiters."
;;
;;;###autoload
-(defun ethio-composition-function (pos to font-object string)
+(defun ethio-composition-function (pos to font-object string _direction)
(setq pos (1- pos))
(let ((pattern "\\ce\\(፟\\|\\)"))
(if string
diff --git a/lisp/language/hebrew.el b/lisp/language/hebrew.el
index c004337c2f8..52188f44725 100644
--- a/lisp/language/hebrew.el
+++ b/lisp/language/hebrew.el
@@ -152,7 +152,7 @@ Bidirectional editing is supported.")))
;; (3) If the font has precomposed glyphs, use them as far as
;; possible. Adjust the remaining glyphs artificially.
-(defun hebrew-shape-gstring (gstring)
+(defun hebrew-shape-gstring (gstring direction)
(let* ((font (lgstring-font gstring))
(otf (font-get font :otf))
(nchars (lgstring-char-len gstring))
@@ -172,7 +172,7 @@ Bidirectional editing is supported.")))
((or (assq 'hebr (car otf)) (assq 'hebr (cdr otf)))
;; FONT has OpenType features for Hebrew.
- (font-shape-gstring gstring))
+ (font-shape-gstring gstring direction))
(t
;; FONT doesn't have OpenType features for Hebrew.
@@ -217,7 +217,7 @@ Bidirectional editing is supported.")))
;; Now IDX is an index to the first non-precomposed glyph.
;; Adjust positions of the remaining glyphs artificially.
(if (font-get font :combining-capability)
- (font-shape-gstring gstring)
+ (font-shape-gstring gstring direction)
(setq base-width (lglyph-width (lgstring-glyph gstring 0)))
(while (< idx nglyphs)
(setq glyph (lgstring-glyph gstring idx))
diff --git a/lisp/language/ind-util.el b/lisp/language/ind-util.el
index 85e99181b5c..e5eaf1cb4a4 100644
--- a/lisp/language/ind-util.el
+++ b/lisp/language/ind-util.el
@@ -829,6 +829,9 @@ Returns new end position."
(let ((pos from) newpos func (max to))
(narrow-to-region from to)
(while (< pos max)
+ ;; FIXME: The below seems to assume
+ ;; composition-function-table holds functions? That is no
+ ;; longer true, since long ago.
(setq func (aref composition-function-table (char-after pos)))
(if (fboundp func)
(setq newpos (funcall func pos nil)
diff --git a/lisp/language/japanese.el b/lisp/language/japanese.el
index f6d9e1bf450..b1fb56980a4 100644
--- a/lisp/language/japanese.el
+++ b/lisp/language/japanese.el
@@ -248,7 +248,7 @@ eucJP-ms is defined in <http://www.opengroup.or.jp/jvc/cde/appendix.html>."
(define-translation-table 'unicode-to-jisx0213
(char-table-extra-slot table 0)))
-(defun compose-gstring-for-variation-glyph (gstring)
+(defun compose-gstring-for-variation-glyph (gstring _direction)
"Compose glyph-string GSTRING for graphic display.
GSTRING must have two glyphs; the first is a glyph for a han character,
and the second is a glyph for a variation selector."
diff --git a/lisp/language/lao-util.el b/lisp/language/lao-util.el
index 554f7cfd83a..4d58be2fc57 100644
--- a/lisp/language/lao-util.el
+++ b/lisp/language/lao-util.el
@@ -489,10 +489,10 @@ syllable. In that case, FROM and TO are indexes to STR."
lao-str)))
;;;###autoload
-(defun lao-composition-function (gstring)
+(defun lao-composition-function (gstring direction)
(if (= (lgstring-char-len gstring) 1)
- (compose-gstring-for-graphic gstring)
- (or (font-shape-gstring gstring)
+ (compose-gstring-for-graphic gstring direction)
+ (or (font-shape-gstring gstring direction)
(let ((glyph-len (lgstring-glyph-len gstring))
(i 0)
glyph)
diff --git a/lisp/language/misc-lang.el b/lisp/language/misc-lang.el
index c1aa79cae45..e25e63b4c5c 100644
--- a/lisp/language/misc-lang.el
+++ b/lisp/language/misc-lang.el
@@ -101,8 +101,8 @@ thin (i.e. 1-dot width) space."
;; Record error in arabic-change-gstring.
(defvar arabic-shape-log nil)
-(defun arabic-shape-gstring (gstring)
- (setq gstring (font-shape-gstring gstring))
+(defun arabic-shape-gstring (gstring direction)
+ (setq gstring (font-shape-gstring gstring direction))
(condition-case err
(when arabic-shaper-ZWNJ-handling
(let ((font (lgstring-font gstring))
diff --git a/lisp/language/thai-util.el b/lisp/language/thai-util.el
index d6c9732a9e8..638d4832d93 100644
--- a/lisp/language/thai-util.el
+++ b/lisp/language/thai-util.el
@@ -225,10 +225,10 @@ positions (integers or markers) specifying the region."
(thai-compose-region (point-min) (point-max)))
;;;###autoload
-(defun thai-composition-function (gstring)
+(defun thai-composition-function (gstring direction)
(if (= (lgstring-char-len gstring) 1)
- (compose-gstring-for-graphic gstring)
- (or (font-shape-gstring gstring)
+ (compose-gstring-for-graphic gstring direction)
+ (or (font-shape-gstring gstring direction)
(let ((glyph-len (lgstring-glyph-len gstring))
(last-char (lgstring-char gstring
(1- (lgstring-char-len gstring))))
diff --git a/lisp/language/tv-util.el b/lisp/language/tv-util.el
index a667956a060..7ce8ee1e500 100644
--- a/lisp/language/tv-util.el
+++ b/lisp/language/tv-util.el
@@ -128,7 +128,7 @@
;;;###autoload
-(defun tai-viet-composition-function (from to font-object string)
+(defun tai-viet-composition-function (from to font-object string _direction)
(if string
(if (string-match tai-viet-re string from)
(tai-viet-compose-string from (match-end 0) string))