[reportlab-users] A Bug in TextObject.moveCursor?
Ian
reportlab-users@reportlab.com
Mon, 15 Mar 2004 21:32:26 -0000
Is moveCursor supposed to be relative?
In all the documentation it quite clearly says:
"""Moves to a point dx, dy away from the start of the
current line - NOT from the current point! So if
you call it in mid-sentence, watch out."""
Which I understood as meaning that it isn't relative to the current
position. You can't issue moveCursor(mm, 0) to move the cursor a millimeter
to the right, for example. You have to do this:
x = to.getX()
to.moveCursor(x + mm, 0)
to get the same effect.
Also if it were strictly relative I wouldn't expect the first moveCursor
command on a line to work properly (it does, even if it occurs almost at the
end of the line - which rules out your theory Mark).
And in any case, even if it was relative, that wouldn't explain the clearly
buggy bit of code
(x,y) = to.getCursor()
to.textOut(text)
(nx, ny) = to.getCursor()
c.line(x,y,nx,ny)
Which should _always_ underline each block of output text (regardless of the
semantics of moveCurosr). But which doesn't work in this case.
Ian
----- Original Message -----
From: "Tim Roberts" <timr@probo.com>
To: <reportlab-users@reportlab.com>
Sent: Monday, March 15, 2004 8:21 PM
Subject: Re: [reportlab-users] A Bug in TextObject.moveCursor?
> 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.
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>