[reportlab-users] A Bug in TextObject.moveCursor?

Tim Roberts reportlab-users@reportlab.com
Mon, 15 Mar 2004 12:21:03 -0800


On Sun, 14 Mar 2004 14:44:55 -0000, "Ian" <reportlab-user@agon.com> wrote:

>I've got a strange problem with TextObject.moveCursor not working =
>properly.
>
>I'm outputting small blocks of text (lyrics - output a few words at a =
>time)
>interspersed by symbols (barlines).
>
>To render my barline, I do this:
>
>    (x, y) =3D to.getCursor() # Find where to draw the barline
>    width =3D drawBarLine(c, x, y, type) # Draw it, and find its width
>    to.moveCursor(x+width, 0) # Move the cursor along by the width
>
>Now the first time this runs on a line, it is fine. The second time the
>moveCursor adds extra space (a couple of cm), then an increasing amout =
>of extra space each time it runs on a line. 
>

Of course it does.  moveCursor is relative: it adds the parameters to 
the current location.  As the cursor moves farther and farther across 
the page, "x" will be getting larger and larger, so the delta will get 
larger and larger.

I think you want this:
    to.moveCursor(width, 0)

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