-
Notifications
You must be signed in to change notification settings - Fork 251
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
Shaping Thai text support #679
Comments
Have you read this section from the documentation?
Page: https://pyfpdf.github.io/fpdf2/Unicode.html We also have an existing issue about supporting ligatures: #540 |
@mrchoke can you please give the Thai text so I can copy/paste it? I am doing some tests integrating harfbuzz on fpdf2 and I'd like to know if it solves your problem too. |
Yes, I read it before. Now FPDF2 can display thai text at sample level. Thai writing system too complex. |
Good news @andersonhc. ok, wait me a while, I'll do it for you as soon as possible. |
Sample Thai text:
Current FPDF2 Render:Expected:Reference: |
Wow, that sounds promising! |
I do have an example with Tibetan, using the NotoSerifTibetan font: from fpdf import FPDF
pdf = FPDF()
pdf.add_page(format=(200,200))
pdf.add_font("NotoSerifTibetan", fname='NotoSerifTibetan-Regular.ttf')
pdf.set_font("NotoSerifTibetan", '', 56)
pdf.write(40, "༄༅། །སྒྲུབ།")
pdf.output("test-tib.pdf") result : expected result (produced with LibreOffice Writer): |
My biggest problem is that fpdf2 maps 1 unicode character to 1 glyph on the font, and that doesn't work with font shapers that supports ligatures (multiple characters will render 1 glyph). I changed the SubsetMap to work with Glyphs and did several changes on the "font" code (using classes instead of dictionary). I have some more things to fix, but as soon as I get a working prototype version I'll open a discussion. |
Awesome! Best of luck with this project 😊 |
@andersonhc PR #820 has been merged today. Could you test if that solved your issue @mrchoke? You can install
The documentation is there: https://pyfpdf.github.io/fpdf2/TextShaping.html |
Since this has been released in 2.7.5, I'm going to close this issue. Anyone is free to reopen it or open another one thare are still issues with thai text |
Please explain your intent
Now fpdf2 can display Thai text but it not pretty.
Describe the solution you'd like
Reference for shaping thai text.
Additional context
The text was updated successfully, but these errors were encountered: