Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimal RTL support for single lines #1442

Open
yzn-h opened this issue Feb 2, 2024 · 11 comments
Open

minimal RTL support for single lines #1442

yzn-h opened this issue Feb 2, 2024 · 11 comments
Labels

Comments

@yzn-h
Copy link
Collaborator

yzn-h commented Feb 2, 2024

version=0.1.0-main+4ac9610b

right now this is how
بسم الله الرحمن الرحيم

will look in ghostty
image
and like this in konsole
image

there are multiple issues
first the characters shaping is wrong
in Arabic and Persian each glyph changes shape depending on the glyph behind it and after it for example:

ignore the "e)" it is there just to make the Arabic text left aligned

e) ي + ز + ن
the first letter is "ي" and the last is "ن"
should be shaped like this
e) يـ + ـز + ن
not like this
e) ( ي + ز + ن ) or (ي + ز + ـن)

the second issue is glyph order in each word
e) علي (correct)
even if the first issue was fixed the text will look like this
e) ﻲﻠﻋ (wrong)

the third issue is word ordering, I don't think there is one correct answer there are two options
the first is to not change anything
firstWord secondWord
or make it like konsole
secondWord firstWord

@yzn-h yzn-h added the renderer label Feb 2, 2024
@mitchellh
Copy link
Contributor

I'll say up front I'm not very familiar with RTL languages on computers. I have read the full RTL/Bidi terminal spec here and I don't currently plan on supporting that in the near term since it requires a very significant amount of effort that I'm not ready to put forward. One day, I'd like to support this.

If what you're suggesting can be resolved in a renderer/shaping-only way then I think we can at least get partial RTL support, so I'll keep this open for that. 😄 More research necessary.

Thank you for the example text and screenshots, this will help significantly.

@mitchellh mitchellh changed the title support RTL languages minimal RTL support for single lines Feb 2, 2024
@mitchellh mitchellh added enhancement and removed bug labels May 8, 2024
@asibahi
Copy link

asibahi commented Dec 27, 2024

Hello. I meant to open an issue regarding this but found this one. I am using the 1.0 Dec26 version of Ghostty. I am on MacOS.

The shaping seems to work fine. All the letters are shaped properly. Problem is they are the wrong order. If I were to guess, they are probably passed to the shaper in the opposite order of what they should be. I don't know what shaper you're using, but HarfBuzz and rustybuzz want the text in the logical order and they give you the rendering order from left to right.

minimal example

Image

Here is how it looks (correctly) in Terminal.app

Image

@eifr
Copy link
Contributor

eifr commented Dec 28, 2024

same on fedora 41
kitty(right) ordering the letters correctly:
Image

@motaz-shokry
Copy link

Until the RTL Support added in the future I encourage you to use bicon with ghostty, or use wezterm "it supports RTL very will Image

@mjec
Copy link

mjec commented Dec 30, 2024

Could I suggest a slight tweak to the wording of the features page related to this? That page currently says:

Certain languages like Arabic and Hebrew are also rendered correctly (LTR only).

which is a little like saying "English text renders correctly (backwards only)." I think it would be clearer to say something like:

While only left-to-right text is supported, characters from RTL scripts including Arabic and Hebrew are correctly clustered and rendered.

@mitchellh
Copy link
Contributor

@mjec Happy to make that change, would you be open to PR-ing it to the website repo?

@Flimm
Copy link

Flimm commented Dec 31, 2024

Could I suggest a slight tweak to the wording of the features page related to this? That page currently says:

Certain languages like Arabic and Hebrew are also rendered correctly (LTR only).

which is a little like saying "English text renders correctly (backwards only)." I think it would be clearer to say something like:

While only left-to-right text is supported, characters from RTL scripts including Arabic and Hebrew are correctly clustered and rendered.

Ghostty does not render characters in RTL scripts correctly, though. They are rendered backwards. Would you say olleh is a correct clustering and rendering of hello? It would be much clearer to say that Ghostty does not support RTL scripts (like Arabic and Hebrew).

@mjec
Copy link

mjec commented Dec 31, 2024

Would you say olleh is a correct clustering and rendering of hello?

I would say that each grapheme is correctly clustered and rendered, even though the text direction is wrong. My understanding is individual grapheme clusters in RTL scripts are correctly rendered, though RTL text direction isn't.

If that's incorrect, let me know; I'm certainly not an expert. But if that's correct and you think the proposed text doesn't accurately capture that idea, I'd be very open to suggested changes.

(Ideally this conversation should probably happen on the website repo, but I'm yet to open the promised PR.)

@ShadiZade
Copy link

ShadiZade commented Jan 1, 2025

?hsilgnE troppus yttsohG soeD

@Majoramari
Copy link

The only good RTL terminal I’ve used so far is Konsole.

I hope to see this feature added to Ghostty soon.

I was misled by the documentation claiming it supports Arabic, but it doesn’t handle RTL properly. Instead, it reverses the text—for example, Hello World becomes dlroW olleH.

Image

mjec added a commit to mjec/ghostty-website that referenced this issue Jan 4, 2025
mjec added a commit to mjec/ghostty-website that referenced this issue Jan 4, 2025
As discussed in ghostty-org/ghostty#1442 (comment),
this clarifies that RTL text is not supported, although rendering of
individual grapheme clusters from RTL scripts is done correctly.
@ebraminio
Copy link

ebraminio commented Jan 13, 2025

Maybe libraqm's minimal implementation can be helpful on how to integrate a bidi library with shaper https://github.com/HOST-Oman/libraqm

macOS side, ghostty vs macOS terminal vs iterm2, the second one is correct, the text is "ابراهیم"

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants