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

Ian reportlab-users@reportlab.com
Sun, 14 Mar 2004 14:44:55 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C409D2.EABC5610
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi All

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. On the next line, same story, =
runs
fine the first time, then adds space... and so on.

But strangely, if I do this:

    (x,y) =3D to.getCursor()
    to.textOut(text)
    (nx, ny) =3D to.getCursor()
    c.line(x,y,nx,ny)

every time I print any text (i.e. I'm underlining each bit of text), I
notice that the underlines are in the correct position, and they don't =
match
with the output text (which is further to the right). In otherwords
moveCursor is correctly moving the cursor, but incorrectly moving the =
text
output position!

Any advice, or shall I go digging in the code?

Ian.
------=_NextPart_000_0016_01C409D2.EABC5610
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Hi All<BR><BR>I've got a strange problem with TextObject.moveCursor =
not=20
working properly.<BR><BR>I'm outputting small blocks of text (lyrics - =
output a=20
few words at a time)<BR>interspersed by symbols (barlines).<BR><BR>To =
render my=20
barline, I do this:<BR><BR>&nbsp;&nbsp;&nbsp; (x, y) =3D to.getCursor() =
# Find=20
where to draw the barline<BR>&nbsp;&nbsp;&nbsp; width =3D drawBarLine(c, =
x, y,=20
type) # Draw it, and find its width<BR>&nbsp;&nbsp;&nbsp; =
to.moveCursor(x+width,=20
0) # Move the cursor along by the width<BR><BR>Now the first time this =
runs on a=20
line, it is fine. The second time the<BR>moveCursor adds extra space (a =
couple=20
of cm), then an increasing amout of<BR>extra space each time it runs on =
a line.=20
On the next line, same story, runs<BR>fine the first time, then adds =
space...=20
and so on.<BR><BR>But strangely, if I do this:<BR><BR>&nbsp;&nbsp;&nbsp; =
(x,y) =3D=20
to.getCursor()<BR>&nbsp;&nbsp;&nbsp; =
to.textOut(text)<BR>&nbsp;&nbsp;&nbsp; (nx,=20
ny) =3D to.getCursor()<BR>&nbsp;&nbsp;&nbsp; =
c.line(x,y,nx,ny)<BR><BR>every time I=20
print any text (i.e. I'm underlining each bit of text), I<BR>notice that =
the=20
underlines are in the correct position, and they don't match<BR>with the =
output=20
text (which is further to the right). In otherwords<BR>moveCursor is =
correctly=20
moving the cursor, but incorrectly moving the text<BR>output=20
position!<BR><BR>Any advice, or shall I go digging in the=20
code?<BR><BR>Ian.</DIV></BODY></HTML>

------=_NextPart_000_0016_01C409D2.EABC5610--