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

bard stéphane stephane.bard at gmail.com
Tue Nov 7 16:30:17 EST 2006


hi all
i've rewrite flowable paragraph and flowable xpreformated classes
to do that
are you interesting by my code ?
example : xpreformated("xml....",style,compress=80.0)
where compress is the amount of squish
same thing for paragraph. I've use it to squish text in table cells
(you should use stringwidth to get the good squish percent)

(it works with reportlab 1.2 and 2.0)

Tim Roberts a écrit :
> 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()
>
>   



More information about the reportlab-users mailing list