-
Notifications
You must be signed in to change notification settings - Fork 261
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
I cannot render Khmer Unicode Properly in PDF file. #700
Comments
Hi @ezzhop From reingart#206:
The code you provided is 84 lines long, it's not "minimal".
I think you missed to include the link in your issue description.
|
there seems to be a solution under development on https://github.com/andersonhc/fpdf2/tree/harfbuzz |
@allcontributors please add @eroux for question |
I've put up a pull request to add @eroux! 🎉 |
I am trying to update library but still be a problem |
harfbuzz just a proof of concept. pdf = FPDF()
pdf.add_page()
pdf.add_font('Battambang', fname='Battambang/Battambang-Regular.ttf')
pdf.set_font("Battambang", size=12)
pdf.harfbuzz_text(
x=15,
y=15,
txt='មនុស្សទាំងអស់រស់នៅលើផែនដីមិនមែនគ្រាន់តែជាការសប្បាយនោះទេ តែវាជាការចូលរួមចំណែកនូវសោកនាថកម្មដ៏អស្ចារ្យ។'
)
pdf.harfbuzz_text(
x=15,
y=30,
txt='ប្រុសឬ ស្រីកើតមកមានសេចក្តីស្រលាញ់តែមួយគត់ក្នុងពេលវេលាដូចគ្នា។'
)
pdf.harfbuzz_text(
x=15,
y=45,
txt='ដោយយល់ឃើញថា ជាការចាំបាច់មិនអោយមានការដាច់ពូជមនុស្ស មនុស្សត្រូវមានមនោសញ្ចេតនា។'
)
pdf.output('khr.pdf') |
Where to define pdf.harfbuzz_text(
|
pip install git+https://github.com/andersonhc/fpdf2.git@harfbuzz pip install uharfbuzz |
Okay, Thank you very much. Now it is working, |
I don't recommend using this fork in your projects unless you have a very urgent need. The definitive solution into the main pyfpdf2 library is being worked on and will be available in a few weeks. |
@andersonhc PR #820 has been merged today. Could you test if that solved your issue @kuth-chi? You can install
|
It's fixed |
Perfect! Thank you @kuth-chi Closing this now |
I have a problem to render PDF in Khmer language (Unicode font).
Error details
My project is work Cambodian so I want to generate PDF in Khmer language by using font Battambang (I downloaded from here: https://fonts.google.com/specimen/Battambang?subset=khmer¬o.script=Khmr). I tested the font in text editor is "Notepad" it is working properly.
But when I render from FPDF2 with Python. the position of characters is not properly. Something is not in order.
Minimal code
Here is my code to generate PDF:
I have downloaded the font and place it in a directory named font in the project.
I created two files in the project directory are "chapter1.txt" is in Khmer and another one is "chapter2.txt" is in English find with attachment files.
chapter1.txt
chapter2.txt
Environment
fpdf2
version: 2.6.1Result of generated PDF (output
output.pdf
.pdf)
The text was updated successfully, but these errors were encountered: