[reportlab-users] registerFont stays how long in memory? what s the best place to register a font?

Thomas Kremmel thomasspin at gmail.com
Thu Apr 15 09:17:31 EDT 2010


Thank you for your detailed response. But I have to admit that I made the
most stupid error you can think of, since I forgot to install the _*rl_accel
*_.pyd at the production server and I think that this could be the problem,
since font loading does use _*rl_accel*_.py .

I will install this package and will see how it behaves. Interestingly the
process worked always about a day and then the described problem occurs.
I will post back when my admin installed the packages and the new setting is
running for a day. I hope this is the problem.


>> Is it mod_python, FastCGI, something else? We need to know a bit about

process lifetimes

in the traceback its written, mod_wsgi , but I do not run the server


>> Are you able to take out the error handling and get us the full

traceback?

Traceback (most recent call last):



File
"/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line
92, in get_response

response = callback(request, *callback_args, **callback_kwargs)



File
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py",
line 78, in __call__

return self.view_func(request, *args, **kwargs)



File "..../export.py", line 270, in export_hour_record

pdf_export = export_objects_as_pdf(request, 'hour_record',
hour_records_month_user_project, user_object)



File ".../export_util.py", line 467, in export_objects_as_pdf

p.setFont("Calibri", 7)



File "/usr/lib/python2.6/dist-packages/reportlab/pdfgen/canvas.py", line
1378, in setFont

font = pdfmetrics.getFont(self._fontname)



File "/usr/lib/python2.6/dist-packages/reportlab/pdfbase/pdfmetrics.py",
line 662, in findFontAndRegister

face = getTypeFace(fontName)



File "/usr/lib/python2.6/dist-packages/reportlab/pdfbase/pdfmetrics.py",
line 621, in getTypeFace

return _typefaces[faceName]



KeyError: 'Calibri'


>> In the cases where setFont failed, did you get a message from

the preceding registerFont call too?

no


>> Is there just one machine, or some kind of a cluster?

one machine, but static content (like fonts, pictures) are served via a
separate server.


>>Are there other calls to registerFont anywhere else in the program? Maybe

if something is 're-registering' while something else is trying to use it
there could be a problem?

two procedures are using the posted code. thus both are registering the
font if it is not registered already.


>>Can you reproduce this problem with a 'hello-world' style self-contained

view, so we could try it here?

it's a bit tricky to reproduce the problem, since in my dev-settings it
works without problems. But probably (and I hope so) the problem is related
to the not-installed _rl_accel_ .. which would be pretty embarrassing ;-)



2010/4/15 Andy Robinson <andy at reportlab.com>


> On 14 April 2010 23:41, Thomas Kremmel <thomasspin at gmail.com> wrote:

> > I really have no clue what is wrong and I'm wondering whether this font

> > loading is maybe buggy?

>

> I doubt it's the font loading per se, as we have been serving many

> hundreds of thousands of PDFs per month out of all Django versions

> since it was launched, and each document needs to load custom fonts.

> A few more random questions....

>

> Is it mod_python, FastCGI, something else? We need to know a bit

> about process lifetimes

>

> Are you able to take out the error handling and get us the full traceback?

>

> In the cases where setFont failed, did you get a message from the

> preceding registerFont call too?

>

> Is there just one machine, or some kind of a cluster?

>

> Are there other calls to registerFont anywhere else in the program?

> Maybe if something is 're-registering' while something else is trying

> to use it there could be a problem?

>

> Can you reproduce this problem with a 'hello-world' style

> self-contained view, so we could try it here?

>

>

>

> --

> Andy

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100415/646d8ab1/attachment.html>


More information about the reportlab-users mailing list