summaryrefslogtreecommitdiff
path: root/src/font.c
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 /src/font.c
parent1a80b5d9b8cfa0e523b596db5d1e7e6074dbee46 (diff)
downloademacs-48776b70115edf3775df19d80f734048dadff198.tar.gz
emacs-48776b70115edf3775df19d80f734048dadff198.tar.bz2
emacs-48776b70115edf3775df19d80f734048dadff198.zip
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 'src/font.c')
-rw-r--r--src/font.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/font.c b/src/font.c
index e81c267de41..fc8efa7f235 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4397,18 +4397,22 @@ font_fill_lglyph_metrics (Lisp_Object glyph, Lisp_Object font_object)
}
-DEFUN ("font-shape-gstring", Ffont_shape_gstring, Sfont_shape_gstring, 1, 1, 0,
- doc: /* Shape the glyph-string GSTRING.
+DEFUN ("font-shape-gstring", Ffont_shape_gstring, Sfont_shape_gstring, 2, 2, 0,
+ doc: /* Shape the glyph-string GSTRING subject to bidi DIRECTION.
Shaping means substituting glyphs and/or adjusting positions of glyphs
to get the correct visual image of character sequences set in the
header of the glyph-string.
+DIRECTION should be produced by the UBA, the Unicode Bidirectional
+Algorithm, and should be a symbol, either L2R or R2L. It can also
+be nil if the bidi context is unknown.
+
If the shaping was successful, the value is GSTRING itself or a newly
created glyph-string. Otherwise, the value is nil.
See the documentation of `composition-get-gstring' for the format of
GSTRING. */)
- (Lisp_Object gstring)
+ (Lisp_Object gstring, Lisp_Object direction)
{
struct font *font;
Lisp_Object font_object, n, glyph;
@@ -4427,7 +4431,7 @@ GSTRING. */)
/* Try at most three times with larger gstring each time. */
for (i = 0; i < 3; i++)
{
- n = font->driver->shape (gstring);
+ n = font->driver->shape (gstring, direction);
if (FIXNUMP (n))
break;
gstring = larger_vector (gstring,
@@ -5350,6 +5354,10 @@ syms_of_font (void)
DEFSYM (QCuser_spec, ":user-spec");
+ /* For shapers that need to know text directionality. */
+ DEFSYM (QL2R, "L2R");
+ DEFSYM (QR2L, "R2L");
+
staticpro (&scratch_font_spec);
scratch_font_spec = Ffont_spec (0, NULL);
staticpro (&scratch_font_prefer);