PDFs with ReportLab in Django. Punjabi Unicode (e.g., ਵਿਰੋਧ ਦੇ ਸਮੇਂ ਫਾਸ਼ੀਵਾਦ) is not displaying correctly. Need font solution
def generate_punjabi_pdf(request):
font_path = os.path.join(settings.BASE_DIR, 'static/myapp/css/fonts/Noto_Sans_Gurmukhi/static', 'NotoSansGurmukhi-Regular.ttf')
pdfmetrics.registerFont(TTFont('NotoSansGurmukhi', font_path))
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename="punjabi_text.pdf"'
c = canvas.Canvas(response, pagesize=A4)
c.setFont("NotoSansGurmukhi", 16)
c.drawString(100, 750, "ਵਿਰੋਧ ਦੇ ਸਮੇਂ ਫਾਸ਼ੀਵਾਦ")
c.showPage()
c.save()
return response
I've tried using different libraries like fpdf2, but the Sihari of the Punjabi text is misplaced, showing shifted to the next character.