pyfpdf icon indicating copy to clipboard operation
pyfpdf copied to clipboard

Hindi Text not converting properly (Matra and Half Characters)

Open deepaksharma76 opened this issue 6 years ago • 13 comments

Hi,

There is an issue in library while using with Hindi language. If you see the example, given on https://pyfpdf.readthedocs.io/en/latest/Unicode/index.html

Screenshots are taken from example in this page and the PDF (link under example)

It shows the correct input of Hindi text right-placement-of-matra-and-half-character

but when converted to PDF https://github.com/reingart/pyfpdf/raw/master/tutorial/unicode.pdf It shows the WRONG placement of Small Matra (Chhoti e ki matra) and half character. You can notice that the "Chhoti e ki matra" in दुनिया is coming after the character न Same way the half character in नमस्ते is showing like this स् wrong-placement-of-matra-and-half-character

I am searching to get solution for long time on Google and stackoverflow.com, but no one has the correct solution for this issue.

It would be great if you please look into this issue and get resolved it as soon as possible. Lots of people are facing this issue (based on my search for solution on google).

Regards.

deepaksharma76 avatar Jul 01 '18 11:07 deepaksharma76

Any update on the Above please.

deepaksharma76 avatar Jul 31 '18 10:07 deepaksharma76

I am also getting an issue with Hindi font in PDF. But in my case, the Hindi letters are splitting into multiple lines.

pdf.add_font('gargi', '', 'C:\\Windows\\Fonts\\Gargi_2.0.ttf', uni=True)
pdf.set_font('gargi', '', 14)
pdf.write(8, u'Hindi: नमस्ते दुनिया')
pdf.ln(20)
pdf.output("D:/unicode.pdf", 'F')

The output of pdf is show below.

pdf_telugu_issue

venkattarigopula avatar Apr 19 '19 11:04 venkattarigopula

I am having the same issue. Has anyone manage to get this working?

CHOMNANP avatar Feb 07 '20 06:02 CHOMNANP

@venkattarigopula and @deepaksharma76, have you manage to get this working. This is really important for my project. We almost launch and just found this issue with Khmer Unicode.

CHOMNANP avatar Feb 07 '20 09:02 CHOMNANP

No Solution found yet. I lost that project because was not able to provide correct spellings.

deepaksharma76 avatar Feb 07 '20 14:02 deepaksharma76

Just curious if there is anything we can do. Maybe I can help out and fix this, and submit a merge request. Just know I have no idea where to start. Can anyone give me some advise?

CHOMNANP avatar Feb 10 '20 02:02 CHOMNANP

I think i have a slightly better output, not able to figure out when it splits Same Sample code from the doc pages used with Gargi.ttf font downloaded and placed in the windows fonts folder

"हो। गए, उनका एक समय में बड़ा नाम था। पूरे देश में तालाब बनते थे बनाने वाले भी पूरे देश में थे। कहीं यह विद्या जाति के विद्यालय | सिखाई जाती थी"

Here is what my output looks like

image

unicode.pdf

Not sure how to proceed with Unicode, I started experimenting with a Tamil font, given there are no threads for Tamil and I can also understand Hindi using this thread to see if there is any progress.

Happy to research and contribute to making any progress.

vkichu avatar Sep 17 '20 01:09 vkichu

PyFPDF is not maintained anymore, you may want to check PyFPDF/fpdf2 as its successor, with a 99%-compatible API

We ensured in the latest version that it can correctly handle thai text: https://github.com/PyFPDF/fpdf2/issues/184

Lucas-C avatar Sep 01 '21 13:09 Lucas-C

PyFPDF is not maintained anymore, you may want to check PyFPDF/fpdf2 as its successor, with a 99%-compatible API

We ensured in the latest version that it can correctly handle thai text: PyFPDF#184

I am having the same issue even with FPDF2. I have tried using different fonts (Gargi, Mangal, Arjun-Wide, Mukta, Lohit) but all give the wrong result similar to what shown below. Correct hindi text: इण्टरनेट पर हिन्दी के साधन What is printed: Screenshot 2022-03-14 at 5 26 24 PM

namastevis avatar Mar 14 '22 11:03 namastevis

Ok. I really don't know anything about Hindi text and won't be of much help here, but if you want to help fix this in fpdf2, you should report it here: https://github.com/PyFPDF/fpdf2/issues

Lucas-C avatar Mar 14 '22 15:03 Lucas-C

Anyone still need the solution ? Well my problem was not exactly with pdf but i was adding hindi text to a video and faced the same problem with matras. So I tried all different fonts like devnagri, gargi, kamal,etc. then I settled with bhaskar(you need to install bhaskar font on your system). To get proper hindi you need to first convert "नमस्ते, दुनिया!"(unicode) to "Ù×SÌð, ÎéçÙØæ!" (Bhaskar). You can use https://www.pramukhfontconverter.com/hindi .

ashmitsharma avatar Apr 05 '23 05:04 ashmitsharma

Yes, we're looking for solution for this. So do you mean we need to convert Unicode to text first before we can actually use it?

Let us grove a try.

Warm regards, Punleu

On Wed, Apr 5, 2023, 12:09 PM ashmitsharma @.***> wrote:

Anyone still need the solution ? Well my problem was not exactly with pdf but i was adding hindi text to a video and faced the same problem with matras. So I tried all different fonts like devnagri, gargi, kamal,etc. then I settled with bhaskar(you need to install bhaskar font on your system). To get proper hindi you need to first convert "नमस्ते, दुनिया!"(unicode) to "Ù×SÌð, ÎéçÙØæ!" (Bhaskar). You can use https://www.pramukhfontconverter.com/hindi .

— Reply to this email directly, view it on GitHub https://github.com/reingart/pyfpdf/issues/109#issuecomment-1496924952, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNGROWZ3EJ6W32IMPT3Z73W7T467ANCNFSM4FHZGG7A . You are receiving this because you commented.Message ID: @.***>

CHOMNANP avatar Apr 05 '23 05:04 CHOMNANP

Yes, we're looking for solution for this. So do you mean we need to convert Unicode to text first before we can actually use it? Let us grove a try. Warm regards, Punleu On Wed, Apr 5, 2023, 12:09 PM ashmitsharma @.> wrote: Anyone still need the solution ? Well my problem was not exactly with pdf but i was adding hindi text to a video and faced the same problem with matras. So I tried all different fonts like devnagri, gargi, kamal,etc. then I settled with bhaskar(you need to install bhaskar font on your system). To get proper hindi you need to first convert "नमस्ते, दुनिया!"(unicode) to "Ù×SÌð, ÎéçÙØæ!" (Bhaskar). You can use https://www.pramukhfontconverter.com/hindi . — Reply to this email directly, view it on GitHub <#109 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNGROWZ3EJ6W32IMPT3Z73W7T467ANCNFSM4FHZGG7A . You are receiving this because you commented.Message ID: @.>

Yes, Instead of bhaskar font you can also use KrutiDev as I didn't find any good converter for bhaskar font but there are many for Unicode to Krutidev.

ashmitsharma avatar Apr 05 '23 14:04 ashmitsharma