[reportlab-users] precalculate size of textobjects, vector patterns?

Dinu Gherman reportlab-users@reportlab.com
Mon, 24 Mar 2003 10:37:15 +0100


Michael Schulz:

> So, the question: is there a way to precalculate size parameters of
> textobjects and return these values to my application? This calculation
> should take into account the current text rendering settings. In the
> docs i haven't found yet such methods.

If you mean arbitrary strings, you can use the following function: 
reportlab.pdfbase.pdfmetrics.stringWidth.

> And one other, rather a feature question: Is it possible with reportlab
> to fill rectangles with vector patterns (e.g. .eps)?

No, there is limited support for clipping (on the PDF canvas only)
and none for "vector patterns". The SVG renderer could be rather
easily modified to clip anything off a certain path and leave only
what you draw inside. It currently clips everything off the out-
most drawing area only.

You could hack similar stuff like this yourself into RLG, like
I did in reportlab.graphics.widgets.grids, which support some de-
gree of gradients as well, but this is likely a labourious task,
and will be rather ineffective in rendering time and code size
(for vector formats).

Well, actually, you could build a composition widget, consisting
of other widgets spread over a plane following *some* layout and
just care about the clipping at the borders... That would be a
nice contribution! ;-)

To really support demanding GIS applications one does probably
need real PDF/SVG-like pattern support. Also, see my svglib ex-
tension on the RL extensions webpage...

Regards,

Dinu

--
Dinu C. Gherman
......................................................................
"Do you have blacks, too?"
(George W. Bush addressing the President of Brazil, 19 May 2002)