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

HIndi Rendering Problem #293

Open
MayankFawkes opened this issue Apr 7, 2024 · 4 comments
Open

HIndi Rendering Problem #293

MayankFawkes opened this issue Apr 7, 2024 · 4 comments

Comments

@MayankFawkes
Copy link

Incorrent rendering Hindi fonts https://hindi-fonts.com/fonts/mangal-regular

pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
pdf.AddPage()
err := pdf.AddTTFFont("mangal", "mangal.ttf")
if err != nil {
    log.Print(err.Error())
    return
}

err = pdf.SetFont("mangal", "", 14)
if err != nil {
    log.Print(err.Error())
    return
}
pdf.Cell(nil, "नमस्ते")
pdf.WritePdf("hello.pdf")

Output

image

Expected

image

@oneplus1000
Copy link
Collaborator

I'm not 100% sure, but I think this problem is caused by combine 2 letters in to one letters. This problem is more specific to the language than the gopdf lib that tries to act as a simple library for generating PDF will do.

And I've seen a similar solution in Arabic: they take the string through a conversion function before sending it to gopdf.

pdf.Text(reverseString(goarabic.ToGlyph("الايام السبعة")))

@MayankFawkes
Copy link
Author

I don't think do that Arabic thing work with Hindi both are completely different

@oneplus1000
Copy link
Collaborator

I don't mean that goarabic can be used in Hindi. What I mean is that the problem arises the same way as in Arabic, where letters are changed or combined depending on the preceding letter. What you should do is write a character converter similar to goarabic but in hindi.

@MayankFawkes
Copy link
Author

yeah i am looking for something like that i found go-text/typesetting but not sure if we can use it or not or how can we use it so i made issue there go-text/typesetting#159 lets see

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

2 participants