Python reportlab - registerFont - django - font not available after a while

I am wondering what is the best time to register a font for use in reportlab. I added the following line to my .py settings:

pdfmetrics.registerFont(TTFont('Calibri', FONT_DIR + '/fonts/Calibri.ttf'))

      

After this call, the font is available for PDF generation. But it happens that after a few days the font is no longer available and I have to restart the django app, which causes the font to be re-registered.

One approach I already tried was to register the font before each pdf generation call, which didn't work as it crashed every call 3-5.

I just want to know if settings.py is the right place to register a font for reportlab, and if so, what is the reason the font is not available after a few days !?

- Edit -

We actually found that there are some problems with reportlab and mod-wsgi. we switched to fast-cgi and never saw this problem again.

+2


a source to share


1 answer


I don't know what works with Reportlabs at all, but I can tell about django.



Django does not guarantee that parameters will be imported once (there may be other problems too) and this is not a good place for this sort of thing. Usually urls.py is used to register objects (for example, admin.autodiscover).

+1


a source







All Articles