[reportlab-users] Font Helvetica always used?
v+python at g.nevcal.com
Thu Jun 18 15:32:37 EDT 2015
On 6/18/2015 5:08 AM, Robin Becker wrote:
> On 17/06/2015 20:55, Glenn Linderman wrote:
>> On 6/17/2015 5:09 AM, Robin Becker wrote:
>>> If you don't want to mess with the settings overrides then this code
>>> at the
>>> start of your initial script should do the trick
>> So what is the real restriction? This has to be done before what?
>> Before first
>> canvas instantiation, or before other imports, or before what,
> The Canvas class needs a default fontname at instantiation. It can be
> passed in,
But do I understand correctly that simply providing the fontname='arial'
parameter when instantiating the Canvas class could bypass all the
settings weirdness, and/or the initial script hacks?
Except, in looking at Canvas, it doesn't seem to have a fontname
parameter, nor a catchall keyword parameter. So I don't understand your
comment "It can be passed in"... is that just a possibility in a
> I did some experiments with the technique blessed by GvR here
The technique you referenced is mind-blowing!
> def canvas_basefontname():
> from reportlab.pdfbase.ttfonts import TTFont
> from reportlab.pdfbase.pdfmetrics import registerFont,
> return 'arial'
but canvas.basefontname is a property or variable, not a function.
Wouldn't this result in self._fontname being a reference to a function,
instead of the string 'arial'? Or is that one of the side-effects of the
__getattr__ stuff, that the function is called when the property is
referenced? (maybe my mind didn't get blown far enough apart)
> This avoids circular importing which happens otherwise.
I don't understand this comment.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users