tests/test_paragraphs.py
author robin <robin@reportlab.com>
Fri, 23 Mar 2018 16:02:08 +0000
changeset 4389 61a7f0840d00
parent 4367 9960d82643bf
child 4559 51a521ad7dd3
permissions -rw-r--r--
more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4265
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     2
#see license.txt for license details
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
     3
# tests some paragraph styles
4252
fe660f227cac changes for release 3.3.0
robin
parents: 4156
diff changeset
     4
__version__='3.3.0'
4367
9960d82643bf remove ascii, cmp & xrange builtins abuse; version-->3.4.15
robin <robin@reportlab.com>
parents: 4330
diff changeset
     5
from reportlab import xrange
2984
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2967
diff changeset
     6
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2967
diff changeset
     7
setOutDir(__name__)
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
     8
import unittest
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
     9
from reportlab.platypus import Paragraph, SimpleDocTemplate, XBox, Indenter, XPreformatted, PageBreak, Spacer
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    10
from reportlab.lib.styles import ParagraphStyle
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    11
from reportlab.lib.units import inch
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    12
from reportlab.lib.abag import ABag
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    13
from reportlab.lib.colors import red, black, navy, white, green
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    14
from reportlab.lib.randomtext import randomText
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    15
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    16
from reportlab.rl_config import defaultPageSize, rtlSupport
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    17
from reportlab.pdfbase import ttfonts
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    18
from reportlab.pdfbase import pdfmetrics
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
    19
from reportlab.lib.fonts import addMapping, tt2ps
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    20
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    21
(PAGE_WIDTH, PAGE_HEIGHT) = defaultPageSize
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    22
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    23
def myFirstPage(canvas, doc):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    24
    canvas.saveState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    25
    canvas.setStrokeColor(red)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    26
    canvas.setLineWidth(5)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    27
    canvas.line(66,72,66,PAGE_HEIGHT-72)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    28
    canvas.setFont('Times-Bold',24)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    29
    canvas.drawString(108, PAGE_HEIGHT-54, "TESTING PARAGRAPH STYLES")
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    30
    canvas.setFont('Times-Roman',12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    31
    canvas.drawString(4 * inch, 0.75 * inch, "First Page")
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    32
    canvas.restoreState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    33
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    34
def myLaterPages(canvas, doc):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    35
    canvas.saveState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    36
    canvas.setStrokeColor(red)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    37
    canvas.setLineWidth(5)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    38
    canvas.line(66,72,66,PAGE_HEIGHT-72)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    39
    canvas.setFont('Times-Roman',12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    40
    canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    41
    canvas.restoreState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    42
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    43
def getAFont():
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    44
    '''register a font that supports most Unicode characters'''
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    45
    I = []
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    46
    font_name = 'DejaVuSans'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    47
    I.append([(font_name, 0, 0, font_name),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    48
                 (font_name, 1, 0, font_name + '-Bold'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    49
                 (font_name, 0, 1, font_name + '-Oblique'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    50
                 (font_name, 1, 1, font_name + '-BoldOblique'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    51
                 ])
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    52
    font_name = 'FreeSerif'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    53
    I.append([(font_name, 0, 0, font_name),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    54
                 (font_name, 1, 0, font_name + 'Bold'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    55
                 (font_name, 0, 1, font_name + 'Italic'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    56
                 (font_name, 1, 1, font_name + 'BoldItalic'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    57
                 ])
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    58
    for info in I:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    59
        n = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    60
        for font in info:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    61
            fontName = font[3]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    62
            try:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    63
                pdfmetrics.registerFont(ttfonts.TTFont(fontName,fontName + '.ttf'))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    64
                addMapping(*font)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    65
                n += 1
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    66
            except:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    67
                pass
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
    68
        if n==4: return font[0]
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    69
    raise ValueError('could not find suitable font')
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    70
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    71
class ParagraphTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    72
    "Test Paragraph class (eyeball-test)."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    73
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    74
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    75
        """Test...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    76
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    77
        The story should contain...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    78
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    79
        Features to be visually confirmed by a human being are:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    80
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    81
            1. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    82
            2. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    83
            3. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    84
        """
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    85
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    86
        story = []
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    87
        SA = story.append
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    88
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    89
        #need a style
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    90
        styNormal = ParagraphStyle('normal')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    91
        styGreen = ParagraphStyle('green',parent=styNormal,textColor=green)
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
    92
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    93
        styDots = ParagraphStyle('styDots',parent=styNormal,endDots='.')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    94
        styDots1 = ParagraphStyle('styDots1',parent=styNormal,endDots=ABag(text=' -',dy=2,textColor='red'))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    95
        styDotsR = ParagraphStyle('styDotsR',parent=styNormal,alignment=TA_RIGHT,endDots=' +')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    96
        styDotsC = ParagraphStyle('styDotsC',parent=styNormal,alignment=TA_CENTER,endDots=' *')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    97
        styDotsJ = ParagraphStyle('styDotsJ',parent=styNormal,alignment=TA_JUSTIFY,endDots=' =')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    98
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    99
        istyDots = ParagraphStyle('istyDots',parent=styNormal,firstLineIndent=12,leftIndent=6,endDots='.')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   100
        istyDots1 = ParagraphStyle('istyDots1',parent=styNormal,firstLineIndent=12,leftIndent=6,endDots=ABag(text=' -',dy=2,textColor='red'))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   101
        istyDotsR = ParagraphStyle('istyDotsR',parent=styNormal,firstLineIndent=12,leftIndent=6,alignment=TA_RIGHT,endDots=' +')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   102
        istyDotsC = ParagraphStyle('istyDotsC',parent=styNormal,firstLineIndent=12,leftIndent=6,alignment=TA_CENTER,endDots=' *')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   103
        istyDotsJ = ParagraphStyle('istyDotsJ',parent=styNormal,firstLineIndent=12,leftIndent=6,alignment=TA_JUSTIFY,endDots=' =')
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   104
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   105
        styNormalCJK = ParagraphStyle('normal',wordWrap='CJK')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   106
        styDotsCJK = ParagraphStyle('styDots',parent=styNormalCJK,endDots='.')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   107
        styDots1CJK = ParagraphStyle('styDots1',parent=styNormalCJK,endDots=ABag(text=' -',dy=2,textColor='red'))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   108
        styDotsRCJK = ParagraphStyle('styDotsR',parent=styNormalCJK,alignment=TA_RIGHT,endDots=' +')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   109
        styDotsCCJK = ParagraphStyle('styDotsC',parent=styNormalCJK,alignment=TA_CENTER,endDots=' *')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   110
        styDotsJCJK = ParagraphStyle('styDotsJ',parent=styNormalCJK,alignment=TA_JUSTIFY,endDots=' =')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   111
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   112
        istyDotsCJK = ParagraphStyle('istyDots',parent=styNormalCJK,firstLineIndent=12,leftIndent=6,endDots='.')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   113
        istyDots1CJK = ParagraphStyle('istyDots1',parent=styNormalCJK,firstLineIndent=12,leftIndent=6,endDots=ABag(text=' -',dy=2,textColor='red'))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   114
        istyDotsRCJK = ParagraphStyle('istyDotsR',parent=styNormalCJK,firstLineIndent=12,leftIndent=6,alignment=TA_RIGHT,endDots=' +')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   115
        istyDotsCCJK = ParagraphStyle('istyDotsC',parent=styNormalCJK,firstLineIndent=12,leftIndent=6,alignment=TA_CENTER,endDots=' *')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   116
        istyDotsJCJK = ParagraphStyle('istyDotsJ',parent=styNormalCJK,firstLineIndent=12,leftIndent=6,alignment=TA_JUSTIFY,endDots=' =')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   117
        
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   118
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   119
        # some to test
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   120
        stySpaced = ParagraphStyle('spaced',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   121
                                   parent=styNormal,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   122
                                   spaceBefore=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   123
                                   spaceAfter=12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   124
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   125
        SA(Paragraph("This is a normal paragraph. "+ randomText(), styNormal))
3825
31067f5ca74a test_paragraphs.py: fix actual syntax errors
robin
parents: 3721
diff changeset
   126
        SA(Paragraph("There follows a paragraph with only \"&lt;br/&gt;\"", styNormal))
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   127
        SA(Paragraph("<br/>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   128
        SA(Paragraph("This has 12 points space before and after, set in the style. " + randomText(), stySpaced))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   129
        SA(Paragraph("This is normal. " + randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   130
        SA(Paragraph("""<para spacebefore="12" spaceafter="12">
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   131
            This has 12 points space before and after, set inline with
3825
31067f5ca74a test_paragraphs.py: fix actual syntax errors
robin
parents: 3721
diff changeset
   132
            XML tag.  It works too.""" + randomText() + "</para>",
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   133
                      styNormal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   134
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   135
        SA(Paragraph("This is normal. " + randomText(), styNormal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   136
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   137
        styBackground = ParagraphStyle('MyTitle',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   138
                                       fontName='Helvetica-Bold',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   139
                                       fontSize=24,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   140
                                       leading=28,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   141
                                       textColor=white,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   142
                                       backColor=navy)
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   143
        SA(Paragraph("This is a title with a background. ", styBackground))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   144
        SA(Paragraph("""<para backcolor="pink">This got a background from the para tag</para>""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   145
        SA(Paragraph("""<para>\n\tThis has newlines and tabs on the front but inside the para tag</para>""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   146
        SA(Paragraph("""<para>  This has spaces on the front but inside the para tag</para>""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   147
        SA(Paragraph("""\n\tThis has newlines and tabs on the front but no para tag""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   148
        SA(Paragraph("""  This has spaces on the front but no para tag""", styNormal))
4156
e71d19a8699c modify backColor layout behaviour, fix single span backColor, bump to 3.1.43
robin
parents: 4136
diff changeset
   149
        SA(Paragraph("""This has <font color=blue backcolor=pink>blue text with pink background</font> here.""", styNormal))
e71d19a8699c modify backColor layout behaviour, fix single span backColor, bump to 3.1.43
robin
parents: 4136
diff changeset
   150
        SA(Paragraph("""<span color=blue backcolor=pink>&nbsp;Nothing but blue text with pink background.&nbsp;</span>""", styNormal))
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   151
        SA(Paragraph("""This has <i>italic text</i> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   152
        SA(Paragraph("""This has <b>bold text</b> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   153
        SA(Paragraph("""This has <u>underlined text</u> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   154
        SA(Paragraph("""This has <font color=blue><u>blue and <font color=red>red</font> underlined text</u></font> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   155
        SA(Paragraph("""<u>green underlining</u>""", styGreen))
3825
31067f5ca74a test_paragraphs.py: fix actual syntax errors
robin
parents: 3721
diff changeset
   156
        SA(Paragraph("""<u>green <font size="+4"><i>underlining</i></font></u>""", styGreen))
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   157
        SA(Paragraph("""This has m<super>2</super> a superscript.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   158
        SA(Paragraph("""This has m<sub>2</sub> a subscript. Like H<sub>2</sub>O!""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   159
        SA(Paragraph("""This has a font change to <font name=Helvetica>Helvetica</font>.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   160
        #This one fails:
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   161
        #SA(Paragraph("""This has a font change to <font name=Helvetica-Oblique>Helvetica-Oblique</font>.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   162
        SA(Paragraph("""This has a font change to <font name=Helvetica><i>Helvetica in italics</i></font>.""", styNormal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   163
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   164
        SA(Paragraph('''This one uses upper case tags and has set caseSensitive=0: Here comes <FONT FACE="Helvetica" SIZE="14pt">Helvetica 14</FONT> with <STRONG>strong</STRONG> <EM>emphasis</EM>.''', styNormal, caseSensitive=0))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   165
        SA(Paragraph('''The same as before, but has set not set caseSensitive, thus the tags are ignored: Here comes <FONT FACE="Helvetica" SIZE="14pt">Helvetica 14</FONT> with <STRONG>strong</STRONG> <EM>emphasis</EM>.''', styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   166
        SA(Paragraph('''This one uses fonts with size "14pt" and also uses the em and strong tags: Here comes <font face="Helvetica" size="14pt">Helvetica 14</font> with <Strong>strong</Strong> <em>emphasis</em>.''', styNormal, caseSensitive=0))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   167
        SA(Paragraph('''This uses a font size of 3cm: Here comes <font face="Courier" size="3cm">Courier 3cm</font> and normal again.''', styNormal, caseSensitive=0))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   168
        SA(Paragraph('''This is just a very long silly text to see if the <FONT face="Courier">caseSensitive</FONT> flag also works if the paragraph is <EM>very</EM> long. '''*20, styNormal, caseSensitive=0))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   169
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   170
        SA(Indenter("1cm"))
4136
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   171
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2'>1.1</bullet>sample bullet default anchor</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   172
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2'>1.22</bullet>sample bullet default anchor</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   173
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='start'>1.1</bullet>sample bullet start align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   174
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='start'>1.22</bullet>sample bullet start align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   175
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='middle'>1.1</bullet>sample bullet middle align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   176
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='middle'>1.22</bullet>sample bullet middle align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   177
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='end'>1.1</bullet>sample bullet end align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   178
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='end'>1.22</bullet>sample bullet end align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   179
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='numeric'>1.1</bullet>sample bullet numeric align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   180
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='numeric'>1.22</bullet>sample bullet numeric align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   181
        SA(Paragraph("<para><bullet bulletIndent='-0.7cm' bulletOffsetY='2' anchor='numeric'><span color='red'>1</span><span color='green'>.</span><span color='blue'>3</span></bullet>sample bullet numeric align</para>", styNormal))
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   182
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   183
        SA(Paragraph("<para><bullet bulletIndent='-1cm' bulletOffsetY='2'><seq id='s0'/>)</bullet>Indented list bulletOffsetY=2. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   184
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   185
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   186
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   187
        SA(XPreformatted("<para leftIndent='0.5cm' backcolor=pink><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   188
        SA(XPreformatted("<para leftIndent='0.5cm' backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   189
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   190
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   191
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   192
        SA(Paragraph("<para>Indented list using seqChain/Format<seqChain order='s0 s1 s2 s3 s4'/><seqReset id='s0'/><seqFormat id='s0' value='1'/><seqFormat id='s1' value='a'/><seqFormat id='s2' value='i'/><seqFormat id='s3' value='A'/><seqFormat id='s4' value='I'/></para>", stySpaced))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   193
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   194
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   195
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   196
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   197
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   198
        SA(XPreformatted("<para backcolor=pink boffsety='-3'><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list bulletOffsetY=-3.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   199
        SA(XPreformatted("<para backcolor=pink><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   200
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   201
        SA(Paragraph("<para><bullet bulletIndent='-1cm'><seq id='s0'/>)</bullet>Indented list. %s</para>" % randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   202
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   203
        SA(XPreformatted("<para backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   204
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   205
        SA(XPreformatted("<para><bullet bulletIndent='-1cm'><seq id='s2'/>)</bullet>Indented list. line1</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   206
        SA(XPreformatted("<para><bullet bulletIndent='-1cm'><seq id='s2'/>)</bullet>Indented list. line2</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   207
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   208
        SA(XPreformatted("<para backcolor=palegreen><bullet bulletIndent='-1cm'><seq id='s1'/>)</bullet>Indented list.</para>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   209
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   210
        SA(Indenter("-1cm"))
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   211
        
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3623
diff changeset
   212
        for i in range(2):
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   213
            SA(PageBreak())
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   214
            SA(Paragraph('''%s dotted paragraphs''' % (i and 'CJK' or 'Normal'), styNormal))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   215
            SA(Paragraph('''Simple paragraph with dots''', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   216
            SA(Paragraph('''Simple indented paragraph with dots''', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   217
            SA(Paragraph('''Simple centred paragraph with stars''', i and styDotsCCJK or styDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   218
            SA(Paragraph('''Simple centred indented paragraph with stars''', i and istyDotsCCJK or istyDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   219
            SA(Paragraph('''Simple right justified paragraph with pluses, but no pluses''', i and styDotsRCJK or styDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   220
            SA(Paragraph('''Simple right justified indented paragraph with pluses, but no pluses''', i and istyDotsRCJK or istyDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   221
            SA(Paragraph('''Simple justified paragraph with equals''', i and styDotsJCJK or styDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   222
            SA(Paragraph('''Simple justified indented paragraph with equals''', i and istyDotsJCJK or istyDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   223
            SA(Paragraph('''A longer simple paragraph with dots''', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   224
            SA(Paragraph('''A longer simple indented paragraph with dots''', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   225
            SA(Paragraph('A very much' +50*' longer'+' simple paragraph with dots', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   226
            SA(Paragraph('A very much' +50*' longer'+' simple indented paragraph with dots', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   227
            SA(Paragraph('A very much' +50*' longer'+' centred simple paragraph with stars', i and styDotsCCJK or styDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   228
            SA(Paragraph('A very much' +50*' longer'+' centred simple indented paragraph with stars', i and istyDotsCCJK or istyDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   229
            SA(Paragraph('A very much' +50*' longer'+' right justified simple paragraph with pluses, but no pluses', i and styDotsRCJK or styDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   230
            SA(Paragraph('A very much' +50*' longer'+' right justified simple indented paragraph with pluses, but no pluses', i and istyDotsRCJK or istyDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   231
            SA(Paragraph('A very much' +50*' longer'+' justified simple paragraph with equals', i and styDotsJCJK or styDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   232
            SA(Paragraph('A very much' +50*' longer'+' justified simple indented paragraph with equals', i and istyDotsJCJK or istyDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   233
            SA(Paragraph('''Simple paragraph with dashes that have a dy and a textColor.''', i and styDots1CJK or styDots1))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   234
            SA(Paragraph('''Simple indented paragraph with dashes that have a dy and a textColor.''', i and istyDots1CJK or istyDots1))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   235
            SA(Paragraph('''Complex <font color="green">paragraph</font> with dots''', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   236
            SA(Paragraph('''Complex <font color="green">indented paragraph</font> with dots''', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   237
            SA(Paragraph('''Complex centred <font color="green">paragraph</font> with stars''', i and styDotsCCJK or styDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   238
            SA(Paragraph('''Complex centred <font color="green">indented paragraph</font> with stars''', i and istyDotsCCJK or istyDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   239
            SA(Paragraph('''Complex right justfied <font color="green">paragraph</font> with pluses, but no pluses''', i and styDotsRCJK or styDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   240
            SA(Paragraph('''Complex right justfied <font color="green">indented paragraph</font> with pluses, but no pluses''', i and istyDotsRCJK or istyDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   241
            SA(Paragraph('''Complex justfied <font color="green">paragraph</font> with equals''', i and styDotsJCJK or styDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   242
            SA(Paragraph('''Complex justfied <font color="green">indented paragraph</font> with equals''', i and istyDotsJCJK or istyDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   243
            SA(Paragraph('''A longer complex <font color="green">paragraph</font> with dots''', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   244
            SA(Paragraph('''A longer complex <font color="green">indented paragraph</font> with dots''', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   245
            SA(Paragraph('A very much' +50*' longer'+' complex <font color="green">paragraph</font> with dots', i and styDotsCJK or styDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   246
            SA(Paragraph('A very much' +50*' longer'+' complex <font color="green">indented paragraph</font> with dots', i and istyDotsCJK or istyDots))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   247
            SA(Paragraph('''Complex <font color="green">paragraph</font> with dashes that have a dy and a textColor.''', i and styDots1CJK or styDots1))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   248
            SA(Paragraph('''Complex <font color="green">indented paragraph</font> with dashes that have a dy and a textColor.''', i and istyDots1CJK or istyDots1))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   249
            SA(Paragraph('A very much' +50*' longer'+' centred complex <font color="green">paragraph</font> with stars', i and styDotsCCJK or styDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   250
            SA(Paragraph('A very much' +50*' longer'+' centred complex <font color="green">indented paragraph</font> with stars', i and istyDotsCCJK or istyDotsC))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   251
            SA(Paragraph('A very much' +50*' longer'+' right justified <font color="green">complex</font> paragraph with pluses, but no pluses', i and styDotsRCJK or styDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   252
            SA(Paragraph('A very much' +50*' longer'+' right justified <font color="green">complex</font> indented paragraph with pluses, but no pluses', i and istyDotsRCJK or istyDotsR))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   253
            SA(Paragraph('A very much' +50*' longer'+' justified complex <font color="green">paragraph</font> with equals', i and styDotsJCJK or styDotsJ))
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   254
            SA(Paragraph('A very much' +50*' longer'+' justified complex <font color="green">indented paragraph</font> with equals', i and istyDotsJCJK or istyDotsJ))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   255
4389
61a7f0840d00 more controllable under and strike lines; fix for issue 137 contributed by Tom Alexander @ bitbucket; version-->3.4.30
robin <robin@reportlab.com>
parents: 4367
diff changeset
   256
        SA(Paragraph('<para>This image has the image data embedded in the src attribute: <img src="DATA:image/gif;base64,R0lGODdhDwAMAIACAAAAAPf/EiwAAAAADwAMAAACHIyPqcvtCl4ENEQzbc3XnjtV2Dd247mBnva0SwEAOw==" /></para>', styNormal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   257
        template = SimpleDocTemplate(outputfile('test_paragraphs.pdf'),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   258
                                     showBoundary=1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   259
        template.build(story,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   260
            onFirstPage=myFirstPage, onLaterPages=myLaterPages)
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   261
    
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   262
    if rtlSupport:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   263
        def testBidi(self):
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   264
            fontName = getAFont()
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   265
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   266
            # create styles based on the registered font
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   267
            stySTD = ParagraphStyle('STD', fontName = fontName)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   268
            styRJ = ParagraphStyle('RJ', parent=stySTD, alignment=TA_RIGHT)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   269
            styLTR = ParagraphStyle('LTR', parent=stySTD, wordWrap='LTR')
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   270
            styRTL = ParagraphStyle('RTL', parent = stySTD, alignment = TA_RIGHT,
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   271
                                    wordWrap = 'RTL', spaceAfter = 12)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   272
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   273
            # strings for testing Normal & LTR styles
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   274
            ltrStrings = [# English followed by Arabic.
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   275
                          b'English followed by \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   276
                          # English with Arabic in the middle
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   277
                          b'English with \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a in the middle.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   278
                          # English symbols (!@#$%^&*) Arabic
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   279
                          b'English symbols (!@#$%^&*) \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   280
                          # ((testing integers in LTR)) 
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   281
                          b'123 LTR 123 Integers 123.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   282
                          # ((testing decimals in LTR))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   283
                          b'456.78 LTR 456.78 Decimals 456.78.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   284
                          # Long English text with RTL script in the middle, splitting over multiple lines
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   285
                          b'Long \xd8\xb7\xd9\x88\xd9\x8a\xd9\x84 English text'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   286
                              b' \xd9\x86\xd8\xb5 \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a with RTL script'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   287
                              b' \xd9\x83\xd8\xaa\xd8\xa7\xd8\xa8\xd8\xa9 \xd9\x85\xd9\x86'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   288
                              b' \xd8\xa7\xd9\x84\xd9\x8a\xd9\x85\xd9\x8a\xd9\x86 \xd8\xa5\xd9\x84\xd9\x89'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   289
                              b' \xd8\xa7\xd9\x84\xd9\x8a\xd8\xb3\xd8\xa7\xd8\xb1 in the middle,'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   290
                              b' \xd9\x81\xd9\x8a \xd8\xa7\xd9\x84\xd9\x88\xd8\xb3\xd8\xb7\xd8\x8c'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   291
                              b' splitting \xd9\x85\xd9\x82\xd8\xb3\xd9\x85 over \xd8\xb9\xd9\x84\xd9\x89'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   292
                              b' multiple lines \xd8\xb9\xd8\xaf\xd8\xa9 \xd8\xb3\xd8\xb7\xd9\x88\xd8\xb1.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   293
                          ]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   294
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   295
            # strings for testing RTL
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   296
            rtlStrings = [# Arabic followed by English
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   297
                          b'\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a \xd9\x85\xd8\xaa\xd8\xa8\xd9\x88\xd8\xb9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   298
                              b' \xd8\xa8\xd9\x80 English.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   299
                          # Arabic with English in the middle
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   300
                          b'\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a \xd9\x85\xd8\xb9 English \xd9\x81\xd9\x8a'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   301
                              b' \xd8\xa7\xd9\x84\xd9\x85\xd9\x86\xd8\xaa\xd8\xb5\xd9\x81.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   302
                          # Arabic symbols (!@##$%^&*) English
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   303
                          b'\xd8\xb1\xd9\x85\xd9\x88\xd8\xb2 \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   304
                              b' (!@#$%^&*) English.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   305
                          # 123 from right to left 123 integer numbers 123. ((testing integers in RTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   306
                          b'123 \xd9\x85\xd9\x86 \xd8\xa7\xd9\x84\xd9\x8a\xd9\x85\xd9\x8a\xd9\x86'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   307
                              b' \xd8\xa5\xd9\x84\xd9\x89 \xd8\xa7\xd9\x84\xd9\x8a\xd8\xb3\xd8\xa7\xd8\xb1'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   308
                              b' 123 \xd8\xa3\xd8\xb1\xd9\x82\xd8\xa7\xd9\x85'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   309
                              b' \xd8\xb5\xd8\xad\xd9\x8a\xd8\xad\xd8\xa9 123.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   310
                          # 456.78 from right to left 456.78 decimal numbers 456.78. ((testing decimals in RTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   311
                          b'456.78 \xd9\x85\xd9\x86 \xd8\xa7\xd9\x84\xd9\x8a\xd9\x85\xd9\x8a\xd9\x86'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   312
                              b' \xd8\xa5\xd9\x84\xd9\x89 \xd8\xa7\xd9\x84\xd9\x8a\xd8\xb3\xd8\xa7\xd8\xb1'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   313
                              b' 456.78 \xd8\xa3\xd8\xb1\xd9\x82\xd8\xa7\xd9\x85'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   314
                              b' \xd8\xb9\xd8\xb4\xd8\xb1\xd9\x8a\xd8\xa9 456.78.',
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   315
                          # Long Arabic text with LTR text in the middle, splitting over multiple lines
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   316
                          b'\xd9\x86\xd8\xb5 \xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a \xd8\xb7\xd9\x88\xd9\x8a\xd9\x84'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   317
                              b' Long Arabic text \xd9\x85\xd8\xb9 with \xd9\x83\xd8\xaa\xd8\xa7\xd8\xa8\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   318
                              b' \xd9\x85\xd9\x86 \xd8\xa7\xd9\x84\xd9\x8a\xd8\xb3\xd8\xa7\xd8\xb1'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   319
                              b' \xd8\xa5\xd9\x84\xd9\x89 \xd8\xa7\xd9\x84\xd9\x8a\xd9\x85\xd9\x8a\xd9\x86'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   320
                              b' LTR script \xd9\x81\xd9\x8a \xd8\xa7\xd9\x84\xd9\x88\xd8\xb3\xd8\xb7\xd8\x8c'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   321
                              b' in the middle, \xd9\x85\xd9\x82\xd8\xb3\xd9\x85 splitted'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   322
                              b' \xd8\xb9\xd9\x84\xd9\x89 over \xd8\xb9\xd8\xaf\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   323
                              b' \xd8\xb3\xd8\xb7\xd9\x88\xd8\xb1 multiple lines.'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   324
                          ]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   325
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   326
            assert len(ltrStrings) == len(rtlStrings)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   327
            n = len(ltrStrings)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   328
            
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   329
            # create a store to be printed
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   330
            story = []
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   331
            
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   332
            story.append(Paragraph("<b><i>Following pairs of left justified texts have style.wordWrap=None &amp; 'LTR'.</i></b><br/>",stySTD))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   333
            # write every LTR string and its corresponding RTL string to be matched.
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   334
            for i in xrange(n):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   335
                story.append(Paragraph(ltrStrings[i], stySTD))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   336
                story.append(Paragraph(ltrStrings[i], styLTR))
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   337
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   338
            story.append(Paragraph("<br/><b><i>Following pairs of right justfied texts have style.wordWrap=None &amp; 'RTL'.</i></b><br/>",stySTD))
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   339
            for i in xrange(n):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   340
                story.append(Paragraph(rtlStrings[i], styRJ))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   341
                story.append(Paragraph(rtlStrings[i], styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   342
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   343
            story.append(Paragraph("<b><i><br/>Following texts have style.wordWrap='RTL'</i></b>",stySTD))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   344
            # a few additional scripts for testing.
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   345
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   346
                Paragraph(b'\xd9\x87\xd8\xb0\xd9\x87 \xd9\x81\xd9\x82\xd8\xb1\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   347
                              b' \xd8\xb9\xd8\xa7\xd8\xaf\xd9\x8a\xd8\xa9. ', styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   348
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   349
                Paragraph(b'\xd9\x87\xd8\xb0\xd9\x87 \xd8\xa7\xd9\x84\xd9\x81\xd9\x82\xd8\xb1\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   350
                              b' \xd9\x84\xd8\xaf\xd9\x8a\xd9\x87\xd8\xa7 12'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   351
                              b' \xd9\x86\xd9\x82\xd8\xb7\xd8\xa9 \xd9\x82\xd8\xa8\xd9\x84\xd9\x87\xd8\xa7'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   352
                              b' \xd9\x88\xd8\xa8\xd8\xb9\xd8\xaf\xd9\x87\xd8\xa7. ', styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   353
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   354
                Paragraph(b'<para spacebefore="12" spaceafter="12">'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   355
                              b'\xd9\x87\xd8\xb0\xd9\x87 \xd8\xa7\xd9\x84\xd9\x81\xd9\x82\xd8\xb1\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   356
                              b' \xd9\x84\xd8\xaf\xd9\x8a\xd9\x87\xd8\xa7 12 \xd9\x86\xd9\x82\xd8\xb7\xd8\xa9'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   357
                              b' \xd9\x82\xd8\xa8\xd9\x84\xd9\x87\xd8\xa7'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   358
                              b' \xd9\x88\xd8\xa8\xd8\xb9\xd8\xaf\xd9\x87\xd8\xa7\xd8\x8c'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   359
                              b' \xd9\x85\xd8\xad\xd8\xaf\xd8\xaf\xd8\xa9 \xd8\xa8\xd9\x80 XML.'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   360
                              b' \xd8\xa5\xd9\x86\xd9\x87\xd8\xa7 \xd8\xaa\xd8\xb9\xd9\x85\xd9\x84'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   361
                              b' \xd8\xa3\xd9\x8a\xd8\xb6\xd8\xa7! \xd9\x80.'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   362
                              b'</para>',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   363
                          styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   364
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   365
            # TODO: add more RTL scripts to the test (Farsi, Hebrew, etc.)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   366
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   367
            template = SimpleDocTemplate(outputfile('test_paragraphs_bidi.pdf'))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   368
            template.build(story)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   369
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   370
        def testRTLBullets(self):
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   371
            try:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   372
                import mwlib.ext
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   373
            except ImportError:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   374
                pass
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   375
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   376
            font_name = getAFont()
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   377
            doc = SimpleDocTemplate(outputfile('test_rtl_bullets.pdf'),showBoundary=True)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   378
            p_style = ParagraphStyle('default')
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   379
            p_style.leftIndent = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   380
            p_style.rightIndent = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   381
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   382
            list_styles=[ParagraphStyle('list%d' % n) for n in range(3)]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   383
            all_styles = list_styles[:]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   384
            all_styles.append(p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   385
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   386
            direction='rtl'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   387
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   388
            for s in all_styles:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   389
                s.fontSize = 15
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   390
                s.leading = s.fontSize*1.2
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   391
                s.fontName = font_name
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   392
                if direction=='rtl':
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   393
                    s.wordWrap = 'RTL'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   394
                    s.alignment = TA_RIGHT
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   395
                else:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   396
                    s.alignment = TA_JUSTIFY
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   397
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   398
            indent_amount = 20
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   399
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   400
            for list_lvl, list_style in enumerate(list_styles):
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   401
                list_lvl += 1
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   402
                list_style.bulletIndent = indent_amount*(list_lvl-1)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   403
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   404
                if direction=='rtl':
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   405
                    list_style.rightIndent = indent_amount*list_lvl
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   406
                else:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   407
                    list_style.leftIndent = indent_amount*list_lvl
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   408
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   409
            elements =[]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   410
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   411
            TEXTS=[
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   412
                    b'\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f, \xd7\x94\xd7\x95\xd7\x90 \xd7\x94\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x90\xd7\x97\xd7\xa8\xd7\x90\xd7\x99 \xd7\xa2\xd7\x9c \xd7\x9e\xd7\xa9\xd7\xa8\xd7\x93 \xd7\x96\xd7\x94. \xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93 \xd7\x96\xd7\x94 \xd7\xa0\xd7\x97\xd7\xa9\xd7\x91 \xd7\x9c\xd7\x90\xd7\x97\xd7\x93 \xd7\x94\xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93\xd7\x99\xd7\x9d \xd7\x94\xd7\x91\xd7\x9b\xd7\x99\xd7\xa8\xd7\x99\xd7\x9d \xd7\x91\xd7\x9e\xd7\x9e\xd7\xa9\xd7\x9c\xd7\x94. \xd7\x9c\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f \xd7\x9e\xd7\xaa\xd7\x9e\xd7\xa0\xd7\x94 \xd7\x9c\xd7\xa8\xd7\x95\xd7\x91 \xd7\x92\xd7\x9d \xd7\xa1\xd7\x92\xd7\x9f \xd7\xa9\xd7\xa8.',
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   413
                    b'\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f, <b>\xd7\x94\xd7\x95\xd7\x90 \xd7\x94\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x90\xd7\x97\xd7\xa8\xd7\x90\xd7\x99 \xd7\xa2\xd7\x9c \xd7\x9e\xd7\xa9\xd7\xa8\xd7\x93 \xd7\x96\xd7\x94.</b> \xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93 \xd7\x96\xd7\x94 <i>\xd7\xa0\xd7\x97\xd7\xa9\xd7\x91 \xd7\x9c\xd7\x90\xd7\x97\xd7\x93</i> \xd7\x94\xd7\xaa\xd7\xa4\xd7\xa7\xd7\x99\xd7\x93\xd7\x99\xd7\x9d <b><i>\xd7\x94\xd7\x91\xd7\x9b\xd7\x99\xd7\xa8\xd7\x99\xd7\x9d \xd7\x91\xd7\x9e\xd7\x9e\xd7\xa9\xd7\x9c\xd7\x94</i></b>. \xd7\x9c\xd7\xa9\xd7\xa8 \xd7\x94\xd7\x91\xd7\x99\xd7\x98\xd7\x97\xd7\x95\xd7\x9f \xd7\x9e\xd7\xaa\xd7\x9e\xd7\xa0\xd7\x94 \xd7\x9c\xd7\xa8\xd7\x95\xd7\x91 \xd7\x92\xd7\x9d \xd7\xa1\xd7\x92\xd7\x9f \xd7\xa9\xd7\xa8.',
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   414
                    u'<bullet>\u2022</bullet>\u05e9\u05e8 \u05d4\u05d1\u05d9\u05d8\u05d7\u05d5\u05df, <b>\u05d4\u05d5\u05d0 \u05d4\u05e9\u05e8 \u05d4\u05d0\u05d7\u05e8\u05d0\u05d9 \u05e2\u05dc \u05de\u05e9\u05e8\u05d3 \u05d6\u05d4.</b> \u05ea\u05e4\u05e7\u05d9\u05d3 \u05d6\u05d4 <i>\u05e0\u05d7\u05e9\u05d1 \u05dc\u05d0\u05d7\u05d3</i> \u05d4\u05ea\u05e4\u05e7\u05d9\u05d3\u05d9\u05dd <b><i>\u05d4\u05d1\u05db\u05d9\u05e8\u05d9\u05dd \u05d1\u05de\u05de\u05e9\u05dc\u05d4</i></b>. \u05dc\u05e9\u05e8\u05d4\u05d1\u05d9\u05d8\u05d7\u05d5\u05df \u05de\u05ea\u05de\u05e0\u05d4 \u05dc\u05e8\u05d5\u05d1 \u05d2\u05dd \u05e1\u05d2\u05df \u05e9\u05e8.',
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   415
                    ]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   416
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   417
            # simple text in a paragraph
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   418
            # working with patch from Hosam Aly
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   419
            p = Paragraph(TEXTS[0], p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   420
            elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   421
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   422
            elements.append(Spacer(0, 40))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   423
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   424
            # uses intra paragraph markup -> style text
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   425
            p = Paragraph(TEXTS[1], p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   426
            elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   427
            elements.append(Spacer(0, 40))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   428
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   429
            # list item (just a paragraph with a leading <bullet> element
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   430
            for list_style in list_styles:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   431
                p = Paragraph(TEXTS[2], list_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   432
                elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   433
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   434
            doc.build(elements)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   435
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   436
        def testParsing(self):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   437
            fontName = getAFont()
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   438
            fontNameBI = tt2ps(fontName,1,1)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   439
            stySTD = ParagraphStyle('STD',fontName=fontName)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   440
            styBI = ParagraphStyle('BI',fontName=fontNameBI)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   441
            self.assertRaises(ValueError,Paragraph,'aaaa <b><i>bibibi</b></i> ccccc',stySTD)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   442
            self.assertRaises(ValueError,Paragraph,'AAAA <b><i>BIBIBI</b></i> CCCCC',styBI)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   443
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   444
def makeSuite():
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   445
    return makeSuiteForClasses(ParagraphTestCase)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   446
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   447
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   448
if __name__ == "__main__":
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   449
    unittest.TextTestRunner().run(makeSuite())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   450
    printLocation()