[reportlab-users] new branch with possible paragraph measurement fixes
Robin Becker
robin at reportlab.com
Wed Oct 28 13:29:32 EDT 2015
The existing paragraph code has problems doing its width measurements. Consider
Paragraph("
<span fontName=\'Courier\'>Hello</span> World.<ondraw name="_onDrawFunc"
label="end"/>",style)
where style sets up Helvetica 10 points as the base font; this ought to measure
stringWidth('Hello','Courier',10)+stringWidth(' World.','Helvetica',10)
ie 61.67; however, in our paragraph implementation it is thought to measure
64.89 because we have a poor idea of which space to use so we measure a Courier
10 space instead of Helvetica 10.
I have made a branch called para-measure-fix which attempts to fix this issue
and I would ask interested parties to try this branch out. It includes an extra
test in tests/test_platypus_breaking.py which attempts to check this.
You can see the results here
https://www.reportlab.com/static/test_platypus_paragraph_line_lengths-current.pdf
https://www.reportlab.com/static/test_platypus_paragraph_line_lengths-fixed.pdf
the modified test is here
https://www.reportlab.com/static/test_platypus_breaking.py
The branch code also allows some space shrinkage for tight paragraphs using a
new rl_settings parameter spaceShrinkage (a value of 0.05 will allow spaces to
be shrunk by 5%).
--
Robin Becker
More information about the reportlab-users
mailing list