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

Set CSS main direction on bidirectional text #2298

Open
Amirali-Gorji opened this issue Nov 5, 2024 · 4 comments
Open

Set CSS main direction on bidirectional text #2298

Amirali-Gorji opened this issue Nov 5, 2024 · 4 comments
Labels
bug Existing features not working as expected

Comments

@Amirali-Gorji
Copy link

Hi! First, thank you for your fantastic work; I really appreciate it.

I'm encountering an issue with bidirectional (bidi) text when a line starts with English, as shown in the image below:

Image

The expected output should look like this:

Image

I’ve gone through previous issues related to bidi text, but unfortunately, they didn’t resolve this problem.
Any guidance would be greatly appreciated!

@liZe
Copy link
Member

liZe commented Nov 5, 2024

Hi!

Bidi (and even RTL), is not well supported, see #106. But simple cases like this one usually work, thanks to Pango.

In HTML, main direction of text is supposed to be LTR when undefined, that’s probably why the whole text is LTR. Do you have a HTML sample that works in a browser and not in WeasyPrint?

@Amirali-Gorji
Copy link
Author

Actually this picture

Image

captured from an html page , which you can view here

as you can see this html file is RTL but weasyprint output is like bellow picture:

Image

@liZe
Copy link
Member

liZe commented Nov 6, 2024

Thanks for sharing. Here’s a minimal sample:

<meta charset="utf8">
<style>
  p {
    direction: rtl;
    text-align: right;
  }
</style>
<p>با اجرای دستور some command</p>
<p>cloneکردن پروژه :</h2>

I suppose that Pango only guesses the main text direction from the first glyphs. We should instead give the main direction defined by CSS.

@liZe liZe added the bug Existing features not working as expected label Nov 6, 2024
@liZe liZe changed the title bidirectional text Set CSS main direction on bidirectional text Nov 6, 2024
@Amirali-Gorji
Copy link
Author

Thank for your response
I agree with you about Pango.
The HTML appears as shown in the picture below:
Image

However, when I create a PDF file using WeasyPrint, the result appears as shown below:
Image

The direction of second sentence is messed up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants