# [reportlab-users] nbsp and justification problem

Robin Becker robin at reportlab.com
Thu Apr 29 09:50:52 EDT 2010

On 29/04/2010 14:04, Anton Petrushenkov wrote:

> Andy, thanks for good advice!

>

> Robin, what if we make such an alteration:

>

> xpreformatted.py:

> ....

> def _getFragWord(frags):

> ...

> s = s + string.count(text, ' ') # much faster for many blanks

> add line: s = s + string.count(text, u'\xA0')

>

> u'\xA0' - is example, I'm still not sure it'll do the work. I'm now in

> process of trying.

> http://en.wikipedia.org/wiki/Non-breaking_space#Encodings

> Nevertheless, question is: what do you think about such a trick?

.......
unfortunately preformatted is not a good start point since there we intend not
to mess about with the lines at all so justification etc etc should not really
apply.

In paragraph the one which is suppose to be linebreaking/justifying etc etc we
split text into words using a giant regular expression which converts all
whitespace except nbsp into space. Later on near line 292 we're doing

nSpaces += text.count(' ')

which might be the place to check for nbsp if ordinary paragraphs are being
used. In any case I believe we're using utf8 strings internally so we might need
to check for '\xc2\xa0'.
--
Robin Becker