diff --git a/docs/changelog.rst b/docs/changelog.rst index c39ebce49..83bded977 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -19,6 +19,9 @@ To update |kitty|, :doc:`follow the instructions `. - Allow choosing OpenType features for individual fonts via the :opt:`font_features` option. +- Add an option :opt:`force_ltr` to turn off the display of text in RTL scripts + in right-to-eft order (:pull:`2293) + - Allow opening new tabs/windows before the current tab/window as well as after it with the :option:`launch --location` option. diff --git a/kitty/config_data.py b/kitty/config_data.py index ccc2a6104..3e611d490 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -224,6 +224,23 @@ def to_font_size(x): o('font_size', 11.0, long_text=_('Font size (in pts)'), option_type=to_font_size) +o('force_ltr', False, long_text=_(""" +kitty does not support BIDI (bidirectional text), however, for RTL scripts, +words are automatically displayed in RTL. That is +to say, in an RTL script, the words "HELLO WORLD" display in kitty as "WORLD +HELLO", and if you try to select a substring of an RTL-shaped string, you will +get the character that would be there had the the string been LTR. For example, +assuming the Hebrew word ירושלים, selecting the character that on the screen +appears to be ם actually writes into the selection buffer the character י. + +kitty's default behavior is useful in conjunction with a filter to reverse the +word order, however, if you wish to manipulate RTL glyphs, it can be very +challenging to work with, so this option is provided to turn it off. +Furthermore, this option can be used with the command line program +:link:`GNU FriBidi ` to get BIDI +support, because it will force kitty to always treat the text as LTR, which +FriBidi expects for terminals.""")) + def adjust_line_height(x): if x.endswith('%'): @@ -316,6 +333,12 @@ Disable the normal ligatures, but keep the :code:`calt` feature which (in this font) breaks up monotony:: font_features TT2020StyleB-Regular -liga +calt + +In conjunction with :opt:`force_ltr`, you may want to disable Arabic shaping +entirely, and only look at their isolated forms if they show up in a document. +You can do this with e.g.:: + + font_features UnifontMedium +isol -medi -fina -init ''')) diff --git a/kitty/fonts.c b/kitty/fonts.c index d8dee7a1c..0c6d1f43f 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -689,6 +689,7 @@ load_hb_buffer(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_ hb_buffer_add_utf32(harfbuzz_buffer, shape_buffer, num, 0, num); } hb_buffer_guess_segment_properties(harfbuzz_buffer); + if (OPT(force_ltr)) hb_buffer_set_direction(harfbuzz_buffer, HB_DIRECTION_LTR); } diff --git a/kitty/state.c b/kitty/state.c index a73d9603b..04a37d53b 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -527,6 +527,7 @@ PYWRAP1(set_options) { S(macos_thicken_font, PyFloat_AsFloat); S(tab_bar_min_tabs, PyLong_AsUnsignedLong); S(disable_ligatures, PyLong_AsLong); + S(force_ltr, PyObject_IsTrue); S(resize_draw_strategy, PyLong_AsLong); S(resize_in_steps, PyObject_IsTrue); S(pointer_shape_when_grabbed, pointer_shape); diff --git a/kitty/state.h b/kitty/state.h index fad1745a5..5600dfe67 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -43,6 +43,7 @@ typedef struct { Edge tab_bar_edge; unsigned long tab_bar_min_tabs; DisableLigature disable_ligatures; + bool force_ltr; ResizeDrawStrategy resize_draw_strategy; bool resize_in_steps; bool sync_to_monitor;