How to copy and paste RTL languages from PDF (RTL text selection)

Hi

Text selection seems to be broken for Persian.

minimal code to reproduce:

#set text(lang: "en")
This is a sentence.

#set text(lang: "fa")
این یک جمله است.

sel

Hi @Ali, could you add a bit more context? Is the video you added from viewing a compiled PDF? Does the same happen if you use a different program to produce a similar PDF? In that case it would be a bug in the PDF viewer and not in Typst. If the same PDF has the same behavior in other viewers, it’s probably Typst’s fault.

If you can confirm it’s Typst, a bug report would be appreciated.

Finally, could you maybe try to revise your post’s title to be a complete question as per the question guidelines:

Good titles are questions you would ask your friend about Typst.

We hope by adhering to this, we make the information in this forum easy to find in the future. Thanks!

Sorry about the title, I can confirm it’s a bug. So would you please remove this Question. I will open it on Github.

I tested on Firefox internal PDF viewer and Okular (on windows). The text selection behavior strangely was different! however, the pasted texts from two PDF viewer into a text editor app (notepad) are identical and in wrong order.

RTL text is always a challenge. Similar document compiled with Xelatex doesn’t have this particular problem (even though there are problems related with RTL Languages).

Thanks.

1 Like

Hi. Selection in Okular 24.12.3 looks normal.

selection

But I guess the word or char direction is wrong?

This is a sentence.
.تسا هلمج کی نیا

True, The char direction is wrong.

Here’s the Github issue.

1 Like