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

RTL support #126

Open
pikhosh opened this issue Aug 25, 2022 · 10 comments
Open

RTL support #126

pikhosh opened this issue Aug 25, 2022 · 10 comments

Comments

@pikhosh
Copy link

pikhosh commented Aug 25, 2022

Hi! I wanted to know if this library supports RTL languages or not? In terms of writing and also in terms of layout and alignment.

If not, can you please tell me if there is a solution or if you know a library that has this feature?

@fschutt
Copy link
Owner

fschutt commented Aug 25, 2022

RTL - do you mean arabic / hebrew scripts? printpdf does not do text layout because that is way too complex for just PDF. Use https://crates.io/crates/azul-text-layout with inline_text_layout.align_children_horizontal(StyleTextAlignmentHorz::Right);

You can also try genpdf (which is built upon printpdf).

@pikhosh
Copy link
Author

pikhosh commented Aug 25, 2022

RTL - do you mean arabic / hebrew scripts?

Yeah!

You can also try genpdf (which is built upon printpdf).

Thanks! I will try genpdf!

@fschutt
Copy link
Owner

fschutt commented Aug 25, 2022

@pikhosh RTL support is very difficult, I think I tried implementing it in azul-text-layout, but the only Rust crate that can reliably do it is allsorts, which is a very low-level font shaper.

@fschutt
Copy link
Owner

fschutt commented Aug 25, 2022

allsorts supports Arabic, Hindi, Hebrew, Pinyin and other scripts correctly. But it's very low level, so you have to position the glyphs manually. Doing that in a PDF library is simply out of the scope of this library, even though it would be nice to have.

@pikhosh
Copy link
Author

pikhosh commented Aug 25, 2022

@pikhosh RTL support is very difficult, I think I tried implementing it in azul-text-layout, but the only Rust crate that can reliably do it is allsorts, which is a very low-level font shaper.

Yeah... it seems difficult! Even among JS libraries, RTL support is rare! (or maybe I just don't know how to use them 😅)

@fschutt
Copy link
Owner

fschutt commented Aug 25, 2022

I know I once supported Hebrew in azul-text-layout, I also tried supporting Japanese. But I'm not sure if that is still the case.

@pikhosh
Copy link
Author

pikhosh commented Aug 25, 2022

I know I once supported Hebrew in azul-text-layout, I also tried supporting Japanese. But I'm not sure if that is still the case.

azul-text-layout is confusing for me! I've never coded in Rust and azul-text-layout seems to be for its own GUI library, which confuses me more about what it does to help create PDFs...

@fschutt
Copy link
Owner

fschutt commented Aug 25, 2022

@pikhosh you can use it without a GUI, it just does the text layouting: #39 (comment)

Yeah, it's a lot of code to integrate, but allsorts is even more code. In short, I don't know of any "solid" text layouting API that does that.

@adals
Copy link

adals commented Aug 25, 2022

for ref swash and demo it could help

@fschutt
Copy link
Owner

fschutt commented Nov 2, 2024

In 0.8 there is now a text-shaping API using allsorts for glyph layout. Not sure if that will to RTL out-of-the-box but I hope.

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

No branches or pull requests

3 participants