--- a/src/reportlab/platypus/paragraph.py Tue Feb 24 11:35:06 2009 +0000
+++ b/src/reportlab/platypus/paragraph.py Fri Feb 27 17:03:27 2009 +0000
@@ -1118,9 +1118,11 @@
if nText!='' and nText[0]!=' ':
g.text += ' ' + nText
+ ni = 0
for i in w[2:]:
g = i[0].clone()
g.text=i[1]
+ if g.text: ni = 1
words.append(g)
fontSize = g.fontSize
if calcBounds:
@@ -1134,6 +1136,9 @@
maxSize = max(maxSize,fontSize)
maxAscent = max(maxAscent,ascent)
minDescent = min(minDescent,descent)
+ if not nText and ni:
+ #one bit at least of the word was real
+ n+=1
currentWidth = newWidth
else: #either it won't fit, or it's a lineBreak tag
--- a/tests/test_platypus_breaking.py Tue Feb 24 11:35:06 2009 +0000
+++ b/tests/test_platypus_breaking.py Fri Feb 27 17:03:27 2009 +0000
@@ -172,7 +172,7 @@
doc = SimpleDocTemplate(outputfile('test_platypus_breaking1.pdf'))
doc.build(content)
- def test1(self):
+ def test2(self):
sty = ParagraphStyle(name = 'normal')
sty.fontName = 'Times-Roman'
sty.fontSize = 10
@@ -187,6 +187,32 @@
p.allowOrphans = 1
self.assertEqual(len(p.split(20,16)),2) #orphans allowed
+ def test3(self):
+ from reportlab.pdfgen.canvas import Canvas
+
+ aW=307
+ styleSheet = getSampleStyleSheet()
+ bt = styleSheet['BodyText']
+ btj = ParagraphStyle('bodyText1j',parent=bt,alignment=TA_JUSTIFY)
+ p=Paragraph("""<a name='top'/>Subsequent pages test pageBreakBefore, frameBreakBefore and
+ keepTogether attributes. Generated at 1111. The number in brackets
+ at the end of each paragraph is its position in the story. llllllllllllllllllllllllll
+ bbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccc ddddddddddddddddddddd eeeeyyy""",btj)
+
+ w,h=p.wrap(aW,1000)
+ canv=Canvas('test_platypus_paragraph_just.pdf',pagesize=(aW,h))
+ i=len(canv._code)
+ p.drawOn(canv,0,0)
+ ParaCode=canv._code[i:]
+ canv.saveState()
+ canv.setLineWidth(0)
+ canv.setStrokeColorRGB(1,0,0)
+ canv.rect(0,0,aW,h)
+ canv.restoreState()
+ canv.showPage()
+ canv.save()
+ assert ParaCode==['q', '1 0 0 1 0 0 cm', 'q', 'BT 1 0 0 1 0 53.17 Tm 10.082 Tw 12 TL /F2 10 Tf 0 0 0 rg (Subsequent pages test pageBreakBefore, frameBreakBefore and) Tj T* 0 Tw .985 Tw (keepTogether attributes. Generated at 1111. The number in brackets at the) Tj T* 0 Tw 3.78 Tw (end of each paragraph is its position in the story. llllllllllllllllllllllllll) Tj T* 0 Tw 92.38 Tw (bbbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccccc) Tj T* 0 Tw (ddddddddddddddddddddd eeeeyyy) Tj T* ET', 'Q', 'Q']
+
def makeSuite():
return makeSuiteForClasses(BreakingTestCase)