diff options
| author | Eli Zaretskii | 2019-01-02 17:55:45 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-01-02 17:55:45 +0200 |
| commit | 1cef2d7cbea407eaeff5c65e9594e03fabe3bf5e (patch) | |
| tree | 456d095c98137f695d2f6b6cdd94ffd87dee93a7 | |
| parent | 48776b70115edf3775df19d80f734048dadff198 (diff) | |
| download | emacs-1cef2d7cbea407eaeff5c65e9594e03fabe3bf5e.tar.gz emacs-1cef2d7cbea407eaeff5c65e9594e03fabe3bf5e.zip | |
Fix text direction of the HarfBuzz shaping buffer
* src/indent.c (scan_for_column, compute_motion):
* src/xdisp.c (CHAR_COMPOSED_P): Pass PDIR argument to
composition_reseat_it.
* src/composite.c (composition_reseat_it): Accept an
additional argument PDIR that provides the current paragraph's
base direction; all callers changed. Use PDIR to fix
calculation of the DIRECTION argument to autocmp_chars.
(Bug#33944)
* src/composite.h: Include dispextern.h.
(composition_reseat_it): Update prototype.
| -rw-r--r-- | src/composite.c | 20 | ||||
| -rw-r--r-- | src/composite.h | 3 | ||||
| -rw-r--r-- | src/indent.c | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 1 |
4 files changed, 20 insertions, 8 deletions
diff --git a/src/composite.c b/src/composite.c index 48824946e64..7cb97934a20 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -1167,7 +1167,9 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1167 | characters to be composed. FACE, if non-NULL, is a base face of | 1167 | characters to be composed. FACE, if non-NULL, is a base face of |
| 1168 | the character. If STRING is not nil, it is a string containing the | 1168 | the character. If STRING is not nil, it is a string containing the |
| 1169 | character to check, and CHARPOS and BYTEPOS are indices in the | 1169 | character to check, and CHARPOS and BYTEPOS are indices in the |
| 1170 | string. In that case, FACE must not be NULL. | 1170 | string. In that case, FACE must not be NULL. PDIR is the base |
| 1171 | direction of the current paragraph, and is used to calculate the | ||
| 1172 | direction argument to pass to the font shaper. | ||
| 1171 | 1173 | ||
| 1172 | If the character is composed, setup members of CMP_IT (id, nglyphs, | 1174 | If the character is composed, setup members of CMP_IT (id, nglyphs, |
| 1173 | from, to, reversed_p), and return true. Otherwise, update | 1175 | from, to, reversed_p), and return true. Otherwise, update |
| @@ -1176,7 +1178,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1176 | bool | 1178 | bool |
| 1177 | composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, | 1179 | composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, |
| 1178 | ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, | 1180 | ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, |
| 1179 | struct face *face, Lisp_Object string) | 1181 | bidi_dir_t pdir, struct face *face, Lisp_Object string) |
| 1180 | { | 1182 | { |
| 1181 | if (cmp_it->ch == -2) | 1183 | if (cmp_it->ch == -2) |
| 1182 | { | 1184 | { |
| @@ -1206,7 +1208,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1206 | else if (w) | 1208 | else if (w) |
| 1207 | { | 1209 | { |
| 1208 | Lisp_Object lgstring = Qnil; | 1210 | Lisp_Object lgstring = Qnil; |
| 1209 | Lisp_Object val, elt; | 1211 | Lisp_Object val, elt, direction = Qnil; |
| 1210 | 1212 | ||
| 1211 | val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); | 1213 | val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); |
| 1212 | for (EMACS_INT i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)) | 1214 | for (EMACS_INT i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)) |
| @@ -1221,8 +1223,12 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1221 | continue; | 1223 | continue; |
| 1222 | if (XFIXNAT (AREF (elt, 1)) != cmp_it->lookback) | 1224 | if (XFIXNAT (AREF (elt, 1)) != cmp_it->lookback) |
| 1223 | goto no_composition; | 1225 | goto no_composition; |
| 1226 | if (pdir == L2R) | ||
| 1227 | direction = QL2R; | ||
| 1228 | else if (pdir == R2L) | ||
| 1229 | direction = QR2L; | ||
| 1224 | lgstring = autocmp_chars (elt, charpos, bytepos, endpos, | 1230 | lgstring = autocmp_chars (elt, charpos, bytepos, endpos, |
| 1225 | w, face, string, QL2R); | 1231 | w, face, string, direction); |
| 1226 | if (composition_gstring_p (lgstring)) | 1232 | if (composition_gstring_p (lgstring)) |
| 1227 | break; | 1233 | break; |
| 1228 | lgstring = Qnil; | 1234 | lgstring = Qnil; |
| @@ -1246,8 +1252,12 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, | |||
| 1246 | else | 1252 | else |
| 1247 | bpos = CHAR_TO_BYTE (cpos); | 1253 | bpos = CHAR_TO_BYTE (cpos); |
| 1248 | } | 1254 | } |
| 1255 | if (pdir == L2R) | ||
| 1256 | direction = QR2L; | ||
| 1257 | else if (pdir == R2L) | ||
| 1258 | direction = QL2R; | ||
| 1249 | lgstring = autocmp_chars (elt, cpos, bpos, charpos + 1, w, face, | 1259 | lgstring = autocmp_chars (elt, cpos, bpos, charpos + 1, w, face, |
| 1250 | string, QR2L); | 1260 | string, direction); |
| 1251 | if (! composition_gstring_p (lgstring) | 1261 | if (! composition_gstring_p (lgstring) |
| 1252 | || cpos + LGSTRING_CHAR_LEN (lgstring) - 1 != charpos) | 1262 | || cpos + LGSTRING_CHAR_LEN (lgstring) - 1 != charpos) |
| 1253 | /* Composition failed or didn't cover the current | 1263 | /* Composition failed or didn't cover the current |
diff --git a/src/composite.h b/src/composite.h index ad39a08dca3..44f7ab7f616 100644 --- a/src/composite.h +++ b/src/composite.h | |||
| @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 26 | #define EMACS_COMPOSITE_H | 26 | #define EMACS_COMPOSITE_H |
| 27 | 27 | ||
| 28 | #include "font.h" | 28 | #include "font.h" |
| 29 | #include "dispextern.h" | ||
| 29 | 30 | ||
| 30 | INLINE_HEADER_BEGIN | 31 | INLINE_HEADER_BEGIN |
| 31 | 32 | ||
| @@ -321,7 +322,7 @@ extern void composition_compute_stop_pos (struct composition_it *, | |||
| 321 | Lisp_Object); | 322 | Lisp_Object); |
| 322 | extern bool composition_reseat_it (struct composition_it *, ptrdiff_t, | 323 | extern bool composition_reseat_it (struct composition_it *, ptrdiff_t, |
| 323 | ptrdiff_t, ptrdiff_t, struct window *, | 324 | ptrdiff_t, ptrdiff_t, struct window *, |
| 324 | struct face *, Lisp_Object); | 325 | bidi_dir_t, struct face *, Lisp_Object); |
| 325 | extern int composition_update_it (struct composition_it *, | 326 | extern int composition_update_it (struct composition_it *, |
| 326 | ptrdiff_t, ptrdiff_t, Lisp_Object); | 327 | ptrdiff_t, ptrdiff_t, Lisp_Object); |
| 327 | 328 | ||
diff --git a/src/indent.c b/src/indent.c index 18855768d37..e0d35f87652 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -599,7 +599,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol) | |||
| 599 | if (cmp_it.id >= 0 | 599 | if (cmp_it.id >= 0 |
| 600 | || (scan == cmp_it.stop_pos | 600 | || (scan == cmp_it.stop_pos |
| 601 | && composition_reseat_it (&cmp_it, scan, scan_byte, end, | 601 | && composition_reseat_it (&cmp_it, scan, scan_byte, end, |
| 602 | w, NULL, Qnil))) | 602 | w, NEUTRAL_DIR, NULL, Qnil))) |
| 603 | composition_update_it (&cmp_it, scan, scan_byte, Qnil); | 603 | composition_update_it (&cmp_it, scan, scan_byte, Qnil); |
| 604 | if (cmp_it.id >= 0) | 604 | if (cmp_it.id >= 0) |
| 605 | { | 605 | { |
| @@ -1506,7 +1506,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos, | |||
| 1506 | if (cmp_it.id >= 0 | 1506 | if (cmp_it.id >= 0 |
| 1507 | || (pos == cmp_it.stop_pos | 1507 | || (pos == cmp_it.stop_pos |
| 1508 | && composition_reseat_it (&cmp_it, pos, pos_byte, to, win, | 1508 | && composition_reseat_it (&cmp_it, pos, pos_byte, to, win, |
| 1509 | NULL, Qnil))) | 1509 | NEUTRAL_DIR, NULL, Qnil))) |
| 1510 | composition_update_it (&cmp_it, pos, pos_byte, Qnil); | 1510 | composition_update_it (&cmp_it, pos, pos_byte, Qnil); |
| 1511 | if (cmp_it.id >= 0) | 1511 | if (cmp_it.id >= 0) |
| 1512 | { | 1512 | { |
diff --git a/src/xdisp.c b/src/xdisp.c index 4d9990cf46c..413d64f80c7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6906,6 +6906,7 @@ static next_element_function const get_next_element[NUM_IT_METHODS] = | |||
| 6906 | || ((IT)->cmp_it.stop_pos == (CHARPOS) \ | 6906 | || ((IT)->cmp_it.stop_pos == (CHARPOS) \ |
| 6907 | && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \ | 6907 | && composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \ |
| 6908 | END_CHARPOS, (IT)->w, \ | 6908 | END_CHARPOS, (IT)->w, \ |
| 6909 | (IT)->bidi_it.paragraph_dir, \ | ||
| 6909 | FACE_FROM_ID_OR_NULL ((IT)->f, \ | 6910 | FACE_FROM_ID_OR_NULL ((IT)->f, \ |
| 6910 | (IT)->face_id), \ | 6911 | (IT)->face_id), \ |
| 6911 | (IT)->string))) | 6912 | (IT)->string))) |