[reportlab-users] Problem using FAQ example for embedding font

Andy Robinson andy at reportlab.com
Tue Sep 16 03:31:07 EDT 2008


2008/9/16 Gerry Reno <greno at verizon.net>:

> Why this problem happens is because in a container (here TinyERP but could

> be any) the container itself is initializing the module containing the font

> registration code and then when the user does an update it causes the

> initialization to run again which is rather normal. Maybe another way of

> handling the issue would be that if the font is already registered it should

> just ignore the subsequent attempts or replace the existing registration

> with the new registration rather than throwing an exception. Certainly this

> does not have to be a fatal error.


It's a deliberate safeguard because otherwise people could (and in
fact have) attempted to register several different versions of a
common font name (e.g. "Helvetica") with different encodings or
character sets. We can't just assume the font is the same and this
forces the developer to deal with it by picking unique names for
unique fonts.

The problem is lessened now that we use Unicode everywhere, but I
still think developers should be alerted if they are attempting to
reuse the same name in a single registry. Also, in a long-running
process, we might need to get into 'locking' the structures used by
the widths cache while being updated to stop another document suddenly
finding a half-initialised font - and I really don't want to start
getting into threading issues,

I think it's a bug in TinyERP, and since the author of that package is
(a) using the name RML without our permission, (b) has never replied
to any of our emails asking for modest changes in his web pages and
giving due credit, and (c) has never contributed patches or feedback
of any kind to our open source package, I'm not inclined to make
changes on his behalf or to spend time supporting his users. Sorry,
this is not aimed at you in any way.

If they changed their code implementing the registerFont tags to use a
try/except block, that would solve the problem too - that's what we do
in "Genuine RML(tm)" ;-)


More information about the reportlab-users mailing list