Hi,
I am trying to generate a PDF that contains text in Malayalam font. Everything is working fine but the text is not displaying correctly.
The font named Noto Sans Malayalam is used.
The input text is കോട്ടയം.
The following image shows the output from Reportlab.
Using Google Docs, I have exported a PDF with the same content and it is displaying correctly.
The following image shows the output from Google Docs:
While checking the fonts embedded in the PDF, both reportlab and Google embedded the fonts in different ways.
In reportlab, the font is embedded as WinAnsi format.
But in Google Docs, it is embedded as Identity-H
.png?part=0.1&view=1)
How to make this work correctly using reportlab?
Here is the source code:-
# -*- coding: utf-8 -*-
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import reportlab.rl_config
reportlab.rl_config.warnOnMissingFontGlyphs = 1
pdfmetrics.registerFont(TTFont('Malayalam', '/home/impressads/projects/reportlabtest/NotoSansMalayalam-Regular.ttf'))
c = canvas.Canvas("reportlab-malayalam.pdf")
c.setFont("Malayalam", 14)
c.setAuthor("raj")
c.setTitle("Reportlab Malayalam")
c.drawString(10,800, u"കോട്ടയം".encode('utf-8'))
c.save()