[reportlab-users] Font size, baseline and typography stuff
robin at reportlab.com
Fri Aug 5 12:37:55 EDT 2011
On 05/08/2011 15:44, Andy Robinson wrote:
> On 5 August 2011 14:34, Dinu Gherman<gherman at darwin.in-berlin.de> wrote:
>> I'm just not sure I would expect this to be inside the
>> charts package, though, but maybe in pdfmetrics...
> It happened this way because our charts/shapes package already had a
> 'getBounds' operation - we needed that to dynamically resize charts to
> be just big enough to contain their text labels and titles, and
> sometimes to make sure labels don't overlap - and when you want to
> define that for a text label, Robin realised he could get the paths
> out of freetype2. It doesn't really have anything to do with PDF and
> applies equally when making a bitmap.
> You're right, it would probably make sense to have an equivalent
> function available within pdfmetrics for the many users who don't
> delve into the chart code.
for what it's worth I have fixed (hopefully) Path.getBounds so it doesn't use
the simplistic assumption from the original code.
Testing using some rather extreme paths eg
> from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, definePath, String, Rect
> from reportlab.lib.colors import red, blue, green
> class TPathBounds_002(_DrawingEditorMixin,Drawing):
> def __init__(self,width=400,height=200,*args,**kw):
> sb = self.p.getBounds()
> self._add(self,String(10,self.height-12,'bounds: '+str(sb),fillColor=blue),name=None,validate=None,desc=None)
> if __name__=="__main__": #NORUNTESTS
revealed an error in renderPM (caused by the old version of libart_lgpl); the
bounds were good, but the _renderPM bpath to vpath conversion left out the
It should now be fixed.
More information about the reportlab-users