Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReportLab letter spacing in Paragraph

Tags:

reportlab

Is it possible to set up letter/char spacing in Paragraph Style? I tried to use spaceShrinkage but it doesn't make any difference

like image 220
B.O.V. Avatar asked Nov 07 '22 03:11

B.O.V.


1 Answers

According to the official documentation, p. 30:

The setCharSpace method adjusts one of the parameters of text -- the inter-character spacing.

It's followed by a code sample:

def charspace(canvas):
    from reportlab.lib.units import inch
    textobject = canvas.beginText()
    textobject.setTextOrigin(3, 2.5*inch)
    textobject.setFont("Helvetica-Oblique", 10)
    charspace = 0
    for line in lyrics:
        textobject.setCharSpace(charspace)
        textobject.textLine("%s: %s" %(charspace,line))
        charspace = charspace+0.5
like image 87
Amessihel Avatar answered Dec 15 '22 10:12

Amessihel