[reportlab-users] treatment of space characters

Chris Jerdonek chris.jerdonek at gmail.com
Wed Feb 16 13:56:20 EST 2011


I sent a report on a possible bug a week ago and didn't get a response
back regarding the bug.

The issue was that a paragraph consisting of a literal non-breaking
space u'\xa0' wraps to have zero height. It seems like it should wrap
to have the same height as text consisting of a printable character or
HTML-encoded non-breaking space u' '.

Also, a paragraph consisting of an HTML-encoded space u' ' wraps
to have positive height. It seems like it should wrap to have zero
height (the same as if the text were a literal space).

--Chris



On Wed, Feb 9, 2011 at 2:16 AM, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:

> I'm looking for a string that takes up space but is invisible for

> passing into a Paragraph -- i.e. so the paragraph looks empty but has

> positive height.  The string "&nbsp;" seems to work for this.

>

> While experimenting with this, I noticed some unexpected behavior.

> Both spaces and non-breaking spaces seem to "take up space" when

> encoded as HTML entities, and neither takes up space otherwise:

>

> def check_height(text):

>    para = Paragraph(text, style)

>    height = para.wrap(300, 300)[1]

>    print "%s: %s" % (repr(text), height)

>

> texts = [u"spaces:", u" ", u"&#x20;", u"\u0020",

>         u"non-breaking spaces:", u"&nbsp;", u"&#xa0;", u"\u00A0"]

>

> for text in texts:

>    check_height(text)

>

> This gives--

>

> u'spaces:': 12

> u' ': 0

> u'&#x20;': 12

> u' ': 0

> u'non-breaking spaces:': 12

> u'&nbsp;': 12

> u'&#xa0;': 12

> u'\xa0': 0

>

> Unless I'm doing something wrong, it seems like all strings in the

> first group should yield 0 and all strings in the second 12.

>

> --Chris

>



More information about the reportlab-users mailing list