[reportlab-users] outlined text?

Robin Becker robin at reportlab.com
Mon Nov 12 05:30:33 EST 2007


Dinu Gherman wrote:

> Jason Craig:

>

>> Is it possible to (somewhat easily) draw outlined text either with the

>> raw graphics functions or platypus? I was hoping that simply setting

>> stroke color to black and fill color to white, then drawString would

>> do the trick but it doesn't :(

>

> I'm not aware of such a functionality, but the easiest way to get it,

> is to use outlined fonts, e.g. in TrueType, if you just need a simple

> type of outline and not fancy stuff like double outlines with gradients

> between the lines, etc.

>

> Regards,

>

> Dinu

........

We have drawn outlined fonts in the past using the text rendering mode method in
a TextObject. The following script shows that the render mode seems to persist
outside the text object that creates it.


##########
from reportlab.pdfgen.canvas import Canvas
c = Canvas('hello.pdf')
c.setStrokeColor((1,0,0))
c.setFillColor((0,0,1))
c.setLineWidth(0.5)
t=c.beginText()
t.setTextRenderMode(2)
c._code.append(t.getCode())
c.setFont('Helvetica',36)
c.drawString(72,72,'Hello World')
c.showPage()
c.save()
##########


This technique can probably be made easier, but I can't figure out from the PDF
spec if it is really intended to work this way so be careful.
--
Robin Becker


More information about the reportlab-users mailing list