Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It's possible to create a blurred text with reportlab?

I'm trying to reproduce a blurred/text-shadow effect using reportlab. Something like this.

image

So far my approach was to work with the filling color (the text itself or the background), but I don't think I'm going to be successful if I follow this path because the class only accepts an opacity (alpha) paramater besides the ones that defines the color itself. Now I'm trying to find some font that will mimic this effect.

So, It's possible to reproduce the desirable effect with reportlab? If yes, which approach should I use to achieve it?

Thank you very much!

like image 751
Murilo Sitonio Avatar asked Jan 25 '23 00:01

Murilo Sitonio


1 Answers

I don't see any straightforward way to achieve a blurry effect as you can achieve with CSS or even with the PIL library using reportlab.

You can try one of the following fonts that more-less mimic this effect: Acidic, ExtraBlur, Erthqake Font, Static Buzz Font , vtks trunkset Font and use the pdfmetrics.registerFont() and TTFont() methods (e.g. using the Static Buzz Font):

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

canvas = Canvas('temp.pdf')
pdfmetrics.registerFont(TTFont('StaticBuzz', '/path/to/TTF-file/StaticBuzz.ttf')) #Change the path to the .ttf file.
canvas.setFont('StaticBuzz', 32)
canvas.drawString(0, 700, "Sample usage of StaticBuzz Font.")
canvas.save()
like image 76
Daniel Ocando Avatar answered Jan 28 '23 13:01

Daniel Ocando