tests/test_paragraphs.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4265 4c95cb54c4bd
child 4367 9960d82643bf
permissions -rw-r--r--
changes for release 3.4.0
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'
2984
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2967
diff changeset
     5
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
c63f149d55aa tests.utils --> reportlab.lib.testutils
rgbecker
parents: 2967
diff changeset
     6
setOutDir(__name__)
2966
c9df63ccabdf reportlab-2.2: major changes to make tests run
rgbecker
parents: 2963
diff changeset
     7
import unittest
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
     8
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
     9
from reportlab.lib.styles import ParagraphStyle
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    10
from reportlab.lib.units import inch
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    11
from reportlab.lib.abag import ABag
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    12
from reportlab.lib.colors import red, black, navy, white, green
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    13
from reportlab.lib.randomtext import randomText
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    14
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
    15
from reportlab.rl_config import defaultPageSize, rtlSupport
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    16
from reportlab.pdfbase import ttfonts
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    17
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
    18
from reportlab.lib.fonts import addMapping, tt2ps
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    19
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    20
(PAGE_WIDTH, PAGE_HEIGHT) = defaultPageSize
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    21
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    22
def myFirstPage(canvas, doc):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    23
    canvas.saveState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    24
    canvas.setStrokeColor(red)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    25
    canvas.setLineWidth(5)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    26
    canvas.line(66,72,66,PAGE_HEIGHT-72)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    27
    canvas.setFont('Times-Bold',24)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    28
    canvas.drawString(108, PAGE_HEIGHT-54, "TESTING PARAGRAPH STYLES")
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    29
    canvas.setFont('Times-Roman',12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    30
    canvas.drawString(4 * inch, 0.75 * inch, "First Page")
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    31
    canvas.restoreState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    32
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    33
def myLaterPages(canvas, doc):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    34
    canvas.saveState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    35
    canvas.setStrokeColor(red)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    36
    canvas.setLineWidth(5)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    37
    canvas.line(66,72,66,PAGE_HEIGHT-72)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    38
    canvas.setFont('Times-Roman',12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    39
    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
    40
    canvas.restoreState()
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    41
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    42
def getAFont():
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    43
    '''register a font that supports most Unicode characters'''
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    44
    I = []
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    45
    font_name = 'DejaVuSans'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    46
    I.append([(font_name, 0, 0, font_name),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    47
                 (font_name, 1, 0, font_name + '-Bold'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    48
                 (font_name, 0, 1, font_name + '-Oblique'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    49
                 (font_name, 1, 1, font_name + '-BoldOblique'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    50
                 ])
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    51
    font_name = 'FreeSerif'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    52
    I.append([(font_name, 0, 0, font_name),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    53
                 (font_name, 1, 0, font_name + 'Bold'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    54
                 (font_name, 0, 1, font_name + 'Italic'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    55
                 (font_name, 1, 1, font_name + 'BoldItalic'),
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    56
                 ])
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    57
    for info in I:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    58
        n = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    59
        for font in info:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    60
            fontName = font[3]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    61
            try:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    62
                pdfmetrics.registerFont(ttfonts.TTFont(fontName,fontName + '.ttf'))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    63
                addMapping(*font)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    64
                n += 1
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    65
            except:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    66
                pass
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
    67
        if n==4: return font[0]
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    68
    raise ValueError('could not find suitable font')
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
    69
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    70
class ParagraphTestCase(unittest.TestCase):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    71
    "Test Paragraph class (eyeball-test)."
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    72
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    73
    def test0(self):
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    74
        """Test...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    75
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    76
        The story should contain...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    77
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    78
        Features to be visually confirmed by a human being are:
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    79
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    80
            1. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    81
            2. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    82
            3. ...
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    83
        """
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
        story = []
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    86
        SA = story.append
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    87
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    88
        #need a style
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    89
        styNormal = ParagraphStyle('normal')
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
    90
        styGreen = ParagraphStyle('green',parent=styNormal,textColor=green)
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
    91
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    92
        styDots = ParagraphStyle('styDots',parent=styNormal,endDots='.')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    93
        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
    94
        styDotsR = ParagraphStyle('styDotsR',parent=styNormal,alignment=TA_RIGHT,endDots=' +')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    95
        styDotsC = ParagraphStyle('styDotsC',parent=styNormal,alignment=TA_CENTER,endDots=' *')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    96
        styDotsJ = ParagraphStyle('styDotsJ',parent=styNormal,alignment=TA_JUSTIFY,endDots=' =')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    97
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    98
        istyDots = ParagraphStyle('istyDots',parent=styNormal,firstLineIndent=12,leftIndent=6,endDots='.')
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
    99
        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
   100
        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
   101
        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
   102
        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
   103
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   104
        styNormalCJK = ParagraphStyle('normal',wordWrap='CJK')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   105
        styDotsCJK = ParagraphStyle('styDots',parent=styNormalCJK,endDots='.')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   106
        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
   107
        styDotsRCJK = ParagraphStyle('styDotsR',parent=styNormalCJK,alignment=TA_RIGHT,endDots=' +')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   108
        styDotsCCJK = ParagraphStyle('styDotsC',parent=styNormalCJK,alignment=TA_CENTER,endDots=' *')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   109
        styDotsJCJK = ParagraphStyle('styDotsJ',parent=styNormalCJK,alignment=TA_JUSTIFY,endDots=' =')
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   110
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   111
        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
   112
        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
   113
        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
   114
        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
   115
        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
   116
        
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   117
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   118
        # some to test
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   119
        stySpaced = ParagraphStyle('spaced',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   120
                                   parent=styNormal,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   121
                                   spaceBefore=12,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   122
                                   spaceAfter=12)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   123
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   124
        SA(Paragraph("This is a normal paragraph. "+ randomText(), styNormal))
3825
31067f5ca74a test_paragraphs.py: fix actual syntax errors
robin
parents: 3721
diff changeset
   125
        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
   126
        SA(Paragraph("<br/>", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   127
        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
   128
        SA(Paragraph("This is normal. " + randomText(), styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   129
        SA(Paragraph("""<para spacebefore="12" spaceafter="12">
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   130
            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
   131
            XML tag.  It works too.""" + randomText() + "</para>",
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   132
                      styNormal))
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   133
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   134
        SA(Paragraph("This is normal. " + randomText(), styNormal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   135
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   136
        styBackground = ParagraphStyle('MyTitle',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   137
                                       fontName='Helvetica-Bold',
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   138
                                       fontSize=24,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   139
                                       leading=28,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   140
                                       textColor=white,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   141
                                       backColor=navy)
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   142
        SA(Paragraph("This is a title with a background. ", styBackground))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   143
        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
   144
        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
   145
        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
   146
        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
   147
        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
   148
        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
   149
        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
   150
        SA(Paragraph("""This has <i>italic text</i> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   151
        SA(Paragraph("""This has <b>bold text</b> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   152
        SA(Paragraph("""This has <u>underlined text</u> here.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   153
        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
   154
        SA(Paragraph("""<u>green underlining</u>""", styGreen))
3825
31067f5ca74a test_paragraphs.py: fix actual syntax errors
robin
parents: 3721
diff changeset
   155
        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
   156
        SA(Paragraph("""This has m<super>2</super> a superscript.""", styNormal))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   157
        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
   158
        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
   159
        #This one fails:
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   160
        #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
   161
        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
   162
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   163
        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
   164
        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
   165
        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
   166
        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
   167
        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
   168
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   169
        SA(Indenter("1cm"))
4136
16f067cf3dae added rl_settings.decimalSymbol & support for simple bullet anchoring, version-->3.1.35
robin
parents: 4097
diff changeset
   170
        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
   171
        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
   172
        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
   173
        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
   174
        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
   175
        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
   176
        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
   177
        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
   178
        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
   179
        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
   180
        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
   181
3577
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   182
        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
   183
        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
   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(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   186
        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
   187
        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
   188
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   189
        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
   190
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   191
        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
   192
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   193
        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
   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(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   197
        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
   198
        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
   199
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   200
        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
   201
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   202
        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
   203
        SA(Indenter("1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   204
        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
   205
        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
   206
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   207
        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
   208
        SA(Indenter("-1cm"))
8821ed2f209e test_paragraphs.py: added in endDots cases
rgbecker
parents: 3399
diff changeset
   209
        SA(Indenter("-1cm"))
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   210
        
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3623
diff changeset
   211
        for i in range(2):
3623
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   212
            SA(PageBreak())
0c0bf5fa5a71 test_paragraphs.py: added in CJK tests of endDots
rgbecker
parents: 3617
diff changeset
   213
            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
   214
            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
   215
            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
   216
            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
   217
            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
   218
            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
   219
            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
   220
            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
   221
            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
   222
            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
   223
            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
   224
            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
   225
            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
   226
            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
   227
            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
   228
            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
   229
            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
   230
            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
   231
            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
   232
            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
   233
            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
   234
            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
   235
            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
   236
            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
   237
            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
   238
            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
   239
            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
   240
            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
   241
            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
   242
            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
   243
            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
   244
            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
   245
            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
   246
            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
   247
            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
   248
            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
   249
            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
   250
            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
   251
            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
   252
            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
   253
            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
   254
4265
4c95cb54c4bd allow DATA: scheme in open for read
robin
parents: 4252
diff changeset
   255
        SA(Paragraph('<para>This image has the image data embedded in the src attribute: <img src="DATA:image/gif;base64,R0lGODdhDwAMAIACAAAAAPf/EiwAAAAADwAMAAACHIyPqcvtCl4ENEQzbc3XnjtV2Dd247mBnva0SwEAOw==" />', styNormal))
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   256
        template = SimpleDocTemplate(outputfile('test_paragraphs.pdf'),
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   257
                                     showBoundary=1)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   258
        template.build(story,
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   259
            onFirstPage=myFirstPage, onLaterPages=myLaterPages)
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   260
    
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   261
    if rtlSupport:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   262
        def testBidi(self):
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   263
            fontName = getAFont()
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   264
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   265
            # 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
   266
            stySTD = ParagraphStyle('STD', fontName = fontName)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   267
            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
   268
            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
   269
            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
   270
                                    wordWrap = 'RTL', spaceAfter = 12)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   271
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   272
            # strings for testing Normal & LTR styles
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   273
            ltrStrings = [# English followed by Arabic.
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   274
                          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
   275
                          # English with Arabic in the middle
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   276
                          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
   277
                          # English symbols (!@#$%^&*) Arabic
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   278
                          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
   279
                          # ((testing integers in LTR)) 
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   280
                          b'123 LTR 123 Integers 123.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   281
                          # ((testing decimals in LTR))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   282
                          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
   283
                          # 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
   284
                          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
   285
                              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
   286
                              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
   287
                              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
   288
                              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
   289
                              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
   290
                              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
   291
                              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
   292
                          ]
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
            # strings for testing RTL
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   295
            rtlStrings = [# Arabic followed by English
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   296
                          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
   297
                              b' \xd8\xa8\xd9\x80 English.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   298
                          # Arabic with English in the middle
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   299
                          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
   300
                              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
   301
                          # Arabic symbols (!@##$%^&*) English
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   302
                          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
   303
                              b' (!@#$%^&*) English.',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   304
                          # 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
   305
                          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
   306
                              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
   307
                              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
   308
                              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
   309
                          # 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
   310
                          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
   311
                              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
   312
                              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
   313
                              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
   314
                          # 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
   315
                          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
   316
                              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
   317
                              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
   318
                              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
   319
                              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
   320
                              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
   321
                              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
   322
                              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
   323
                          ]
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
            assert len(ltrStrings) == len(rtlStrings)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   326
            n = len(ltrStrings)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   327
            
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   328
            # create a store to be printed
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   329
            story = []
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   330
            
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   331
            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
   332
            # 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
   333
            for i in xrange(n):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   334
                story.append(Paragraph(ltrStrings[i], stySTD))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   335
                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
   336
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   337
            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
   338
            for i in xrange(n):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   339
                story.append(Paragraph(rtlStrings[i], styRJ))
4094
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   340
                story.append(Paragraph(rtlStrings[i], styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   341
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   342
            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
   343
            # a few additional scripts for testing.
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   344
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   345
                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
   346
                              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
   347
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   348
                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
   349
                              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
   350
                              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
   351
                              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
   352
            story.append(
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   353
                Paragraph(b'<para spacebefore="12" spaceafter="12">'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   354
                              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
   355
                              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
   356
                              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
   357
                              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
   358
                              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
   359
                              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
   360
                              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
   361
                              b'</para>',
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   362
                          styRTL))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   363
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   364
            # 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
   365
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   366
            template = SimpleDocTemplate(outputfile('test_paragraphs_bidi.pdf'))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   367
            template.build(story)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   368
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   369
        def testRTLBullets(self):
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   370
            try:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   371
                import mwlib.ext
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   372
            except ImportError:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   373
                pass
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   374
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   375
            font_name = getAFont()
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   376
            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
   377
            p_style = ParagraphStyle('default')
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   378
            p_style.leftIndent = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   379
            p_style.rightIndent = 0
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   380
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   381
            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
   382
            all_styles = list_styles[:]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   383
            all_styles.append(p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   384
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   385
            direction='rtl'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   386
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   387
            for s in all_styles:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   388
                s.fontSize = 15
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   389
                s.leading = s.fontSize*1.2
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   390
                s.fontName = font_name
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   391
                if direction=='rtl':
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   392
                    s.wordWrap = 'RTL'
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   393
                    s.alignment = TA_RIGHT
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   394
                else:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   395
                    s.alignment = TA_JUSTIFY
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   396
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   397
            indent_amount = 20
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   398
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   399
            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
   400
                list_lvl += 1
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   401
                list_style.bulletIndent = indent_amount*(list_lvl-1)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   402
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   403
                if direction=='rtl':
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   404
                    list_style.rightIndent = indent_amount*list_lvl
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   405
                else:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   406
                    list_style.leftIndent = indent_amount*list_lvl
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   407
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   408
            elements =[]
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   409
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   410
            TEXTS=[
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   411
                    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
   412
                    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
   413
                    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
   414
                    ]
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
            # simple text in a paragraph
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   417
            # working with patch from Hosam Aly
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   418
            p = Paragraph(TEXTS[0], p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   419
            elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   420
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   421
            elements.append(Spacer(0, 40))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   422
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   423
            # uses intra paragraph markup -> style text
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   424
            p = Paragraph(TEXTS[1], p_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   425
            elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   426
            elements.append(Spacer(0, 40))
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   427
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   428
            # 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
   429
            for list_style in list_styles:
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   430
                p = Paragraph(TEXTS[2], list_style)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   431
                elements.append(p)
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   432
186f3923093a transfrred rtl-support changes to default, version --> 3.1.13
robin
parents: 3825
diff changeset
   433
            doc.build(elements)
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   434
4097
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   435
        def testParsing(self):
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   436
            fontName = getAFont()
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   437
            fontNameBI = tt2ps(fontName,1,1)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   438
            stySTD = ParagraphStyle('STD',fontName=fontName)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   439
            styBI = ParagraphStyle('BI',fontName=fontNameBI)
1c2ebf285cb7 paraparser.py: force assertion of tag rather than value checking in end_<tag>
robin
parents: 4094
diff changeset
   440
            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
   441
            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
   442
2963
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   443
def makeSuite():
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   444
    return makeSuiteForClasses(ParagraphTestCase)
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   445
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   446
#noruntests
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   447
if __name__ == "__main__":
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   448
    unittest.TextTestRunner().run(makeSuite())
c414c0ab69e7 reportlab-2.2: first stage of major re-org
rgbecker
parents:
diff changeset
   449
    printLocation()