FPDF add_font python - Bangla Font file xxx.ttf cannot be embedded due to copyright restrictions

2.6k Views Asked by At

from fpdf import FPDF pdf.add_font('SolaimanLipi','','filename.ttf', uni=True)

RuntimeError: ERROR - Font file /content/drive/SolaimanLipi.ttf cannot be embedded due to copyright restrictions.

I have using python fpdf to write bangla in a pdf. But while i use SolaimanLipi font it shows me this error. How can i solve this?

1

There are 1 best solutions below

0
On

Thanks for asking. I had similar issue while trying to create pdf file containing bengali fonts. I checked several fonts and the 'Bangla.ttf' worked for me. You may try the following code in python:

from fpdf import FPDF

pdf=FPDF()

pdf.add_page()
pdf.add_font('bngla', '', 'Bangla.ttf', uni=True)

pdf.set_font("bngla", size=15)

pdf.cell(200,10,txt=" বাংলার গান ",ln=1,align='C')

pdf.output("out.pdf")