[reportlab-users] Text scaling and finding out how much space text will take up

Tim Roberts timr at probo.com
Wed Nov 1 18:11:42 EST 2006


Tim Roberts wrote:

>Andy Robinson wrote:
>  
>
>>Chris Withers wrote:
>>    
>>
>>>Great, yep, I remember it :-)
>>>
>>>Which leaves one question: how do I horizontally scale (ie: squish)
>>>text by a certain amount?
>>>      
>>>
>>canv.saveState()
>>canvas.scale(0.5, 1.0)
>>canv.drawString(x, y, 'half as slim but just as tall')
>>canv.restoreState()
>>    
>>
>
>However, note that "scale" also affects the coordinates.  So you
>probably need something like:
>    canv.drawString( x*2, y, 'half as slim but just as tall')
>

Or, sometimes more convenient:
  canv.saveState()
  canv.translate(x, y)
  canv.scale(0.5, 1.0)
  canv.drawString( 0, 0, 'half as slim but just as tall' )
  canv.restoreState()

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list