-
Notifications
You must be signed in to change notification settings - Fork 269
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
New feature: Handle bidirectional text #882
Comments
Can I work on this if possible please assign this to me. |
Welcome to fpdf2, @mihir1739 !
This issue is currently being worked on in #972. |
@marcstober |
@andersonhc it's working! Thank you for your long-standing help with this issue. Would it be useful for me to add my test file somewhere (an updated version of what I'd posted in #549)? I noticed that selecting the text in a BIDI, RTL paragraph in Acrobat is a bit funny with my test file, and more generally, I'm not sure how fpdf2 knows whether a paragraph is a LTR or RTL paragraph (something I often switch manually in word processing apps). But this might be something I just need to read up the docs or something, and I can always file a new issue for any edge case. Overall I'm happy to see this working and now can go back to some side projects I set aside back when I ran into this over a year ago! |
I just did a small PR adding the option to force paragraph direction. Here is the test file: Also updated the Text Shaping documentation. |
Since text shaping was implemented, fpdf2 can correctly render text in left to right (LTR) or right to left (RTL) direction.
However, if the text provided has both RTL and LTR on the same string, fpdf2 is not applying the bidirectional rules to render the text, as pointed on #549
The problem happens because Harfbuzz will shape the text in one direction only.
If we apply the BIDI algorithm to the input string and break the direction changes into different fragments it should solve this issue as they will be rendered separately.
References:
https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
https://en.wikipedia.org/wiki/Bidirectional_text
Implementations of the BIDI algorithm:
https://github.com/fribidi/fribidi
https://github.com/MeirKriheli/python-bidi
The text was updated successfully, but these errors were encountered: