[reportlab-users] nbsp and justification problem

Anton Petrushenkov wiseman.std at gmail.com
Tue May 4 09:18:41 EDT 2010


Finally, I've found right spot for simple patch. Suppose it's not very
helpful for better performance, but it still makes work done.

After line 324 in paragraphs.py (def _justifyDrawParaLineX):

# Taking NBSP into account
for word in line.words:
if word.text.count(u'\u00A0'):
nSpaces += word.text.count(u'\u00A0')

Suppose it should be included somehow in future releases, but it's up to you
folks.
Thanks for your help.


On 29 April 2010 17:50, Robin Becker <robin at reportlab.com> wrote:


> 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

>

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>




--
http://wisemansoftworks.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100504/470d48c3/attachment.htm>


More information about the reportlab-users mailing list