[reportlab-users] stretching fonts
    Tim Roberts 
    timr at probo.com
       
    Mon Dec 29 13:18:09 EST 2008
    
    
  
Carl Karsten wrote:
> Is there a way to make a font, wider?   or make a string take up x
> amount of space?  the string is a constant (well, it will be "2009"
> for the next year...) and I need it to fill up an area that is about
> 1.5x the width it currently uses, without increasing the hight.  and I
> don't want to just increase the spacing, because I like the look of
> the wider font.
>
> This may qualify as "that is changing the font, and so you should just
> use a different font."   maybe.  but I am trying to use a font that is
> pre-installed on ubuntu boxes.
This is easy.  The canvas.scale method can scale isotropically (meaning
different values in X and Y), and it applies to fonts.  However, you
need to remember that after you apply scale, ALL of the X and Y values
get scaled, including the coordinates you supply to drawString.  The
easy way around this is to do something like this:
    canvas.saveState()
    canvas.translate( myX, myY )  # move origin to desired start of string
    canvas.scale( 1.5, 1.0 )   # scale by 150% in X direction only
    canvas.drawString( 0, 0, "2009" )
    canvas.restoreState()
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
    
    
More information about the reportlab-users
mailing list