How to set font kerning in reportlab python?

247 Views Asked by At

I add font to reportlab, then it generates pdf, but text has kerning turned off. For example in html it works as expected. How to enable font kerning in reportlab ? I have tried changing settings in ParagraphStyle and textObject.setCharSpace but nothing has the desired effect. Below is my sample code and the expected results. Example is available also on my github: https://github.com/czubik8805/ReportLabKerning

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas


pdfmetrics.registerFont(
    TTFont(
        'arial',
        'arial.ttf')
)

c = canvas.Canvas("hello.pdf")
c.setFont('arial', 32)
c.drawString(10, 450, "Toned Avenue")
c.showPage()
c.save()

Text from reportlab (without kerning)

Text from HTML with (kerning)

0

There are 0 best solutions below