Skip to content

Bngali font dosen't show properly on reportlab. #6

Description

@maktum827

I am trying to write Bengali text on report lab using Bengali Unicode font, but it doesn't show properly on report lab. Please solve this problem if it is possible. it shows me this type of text. but the correct will be. 'বাংলা ফন্ট দেখানোর জন্য রিপোর্টল্যাব'
image

Here is my code:
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

Step 1: Register the Bengali font

pdfmetrics.registerFont(TTFont('BengaliFont', 'fonts/SolaimanLipi.ttf'))

Step 2: Create a canvas and set the font

c = canvas.Canvas('bengali_font_example.pdf')
c.setFont('BengaliFont', 12)

Step 3: Write Bengali text

bengali_text = "বাংলা ফন্ট দেখানোর জন্য রিপোর্টল্যাব"
c.drawString(50, 700, bengali_text)

Step 4: Save and close the canvas

c.save()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions