Example #1
0
    def test0(self):
        "A basic document drawing some strings"

        self.luxi = TTFont("DejaVu", "DejaVuSans.ttf")
        pdfmetrics.registerFont(self.luxi)
        # if they do not have the Japanese font files, go away quietly
        # from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile

        ##        enc = 'ETenms-B5-H'
        ##        try:
        ##            findCMapFile(enc)
        ##        except:
        ##            #they don't have the font pack, return silently
        ##            print 'CMap not found'
        ##            return
        # pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))

        c = Canvas(outputfile("test_multibyte_gr.pdf"))
        c.setFont("Helvetica", 24)
        c.drawString(100, 700, "Greek characters Font Support")
        c.setFont("Helvetica", 10)
        c.drawString(100, 680, "Short sample: ")

        hBoxText("Αυτό είναι ενα δοκιμαστικό κείμενο.", c, 100, 600, "DejaVu")

        ##
        c.save()
        if VERBOSE:
            print "saved " + outputfile("test_multibyte_gr.pdf")
Example #2
0
    def test0(self):
        "A basic document drawing some strings"
	
	self.luxi = TTFont("DejaVu", "DejaVuSans.ttf")
        pdfmetrics.registerFont(self.luxi)
        # if they do not have the Japanese font files, go away quietly
        #from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile


##        enc = 'ETenms-B5-H'
##        try:
##            findCMapFile(enc)
##        except:
##            #they don't have the font pack, return silently
##            print 'CMap not found'
##            return
        #pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))

        c = Canvas(outputfile('test_multibyte_gr.pdf'))
        c.setFont('Helvetica', 24)
        c.drawString(100,700, 'Greek characters Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: ')

        hBoxText('Αυτό είναι ενα δοκιμαστικό κείμενο.' , c, 100, 600, 'DejaVu')


##
        c.save()
        if VERBOSE:
            print 'saved '+outputfile('test_multibyte_gr.pdf')
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile


        pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))

        c = Canvas(outputfile('test_multibyte_chs.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100,700, 'Simplified Chinese Font Support')


        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: "China - Zhang Ziyi"  (famous actress)')
        # the two typefaces

        hBoxText('\u4e2d\u56fd - \u7ae0\u5b50\u6021',
                 c,
                 100,
                 660,
                 'STSong-Light',
                 )


        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        c.showPage()

##        # full kuten chart in EUC
##        c.setFont('Helvetica', 18)
##        c.drawString(72,750, 'Characters available in GB 2312-80, EUC encoding')
##        y = 600
##        enc = 'GB_EUC_H'
##        for row in range(1, 95):
##            KutenRowCodeChart(row, 'STSong-Light',enc).drawOn(c, 72, y)
##            y = y - 125
##            if y < 50:
##                c.setFont('Helvetica',10)
##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
##                c.showPage()
##                y = 700
##
        c.save()
        if VERBOSE:
            print('saved '+outputfile('test_multibyte_chs.pdf'))
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile


        pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))

        c = Canvas(outputfile('test_multibyte_chs.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100,700, 'Simplified Chinese Font Support')


        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: "China - Zhang Ziyi"  (famous actress)')
        # the two typefaces

        hBoxText(u'\u4e2d\u56fd - \u7ae0\u5b50\u6021',
                 c,
                 100,
                 660,
                 'STSong-Light',
                 )


        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        c.showPage()

##        # full kuten chart in EUC
##        c.setFont('Helvetica', 18)
##        c.drawString(72,750, 'Characters available in GB 2312-80, EUC encoding')
##        y = 600
##        enc = 'GB_EUC_H'
##        for row in range(1, 95):
##            KutenRowCodeChart(row, 'STSong-Light',enc).drawOn(c, 72, y)
##            y = y - 125
##            if y < 50:
##                c.setFont('Helvetica',10)
##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
##                c.showPage()
##                y = 700
##
        c.save()
        if VERBOSE:
            print 'saved '+outputfile('test_multibyte_chs.pdf')
Example #5
0
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile

        ##        enc = 'ETenms-B5-H'
        ##        try:
        ##            findCMapFile(enc)
        ##        except:
        ##            #they don't have the font pack, return silently
        ##            print 'CMap not found'
        ##            return
        pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))

        c = Canvas(outputfile('test_multibyte_cht.pdf'))
        c.setFont('Helvetica', 24)
        c.drawString(100, 700, 'Traditional Chinese Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(100, 680,
                     'Short sample: "Taiwan  -  Ang Lee" (movie director)')

        hBoxText(u'\u81fa\u7063  -  \u674e\u5b89', c, 100, 600, 'MSung-Light')

        ##        #hBoxText(message3 + ' MHei-Medium', c, 100, 580, 'MHei-Medium', enc)
        ##
        ##
        ##
        ##        c.setFont('Helvetica', 10)
        ##        tx = c.beginText(100, 500)
        ##        tx.textLines("""
        ##            This test document shows Traditional Chinese output from Reportlab PDF Library.
        ##            You may use one Chinese font, MSung-Light, and a number of different
        ##            encodings.
        ##
        ##            The available encoding names (with comments from the PDF specification) are:
        ##            encodings_cht = [
        ##                'B5pc-H',           # Macintosh, Big Five character set, Big Five encoding,
        ##                                    # Script Manager code 2
        ##                'B5pc-V',           # Vertical version of B5pc-H
        ##                'ETen-B5-H',        # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
        ##                                    # character set with ETen extensions
        ##                'ETen-B5-V',        # Vertical version of ETen-B5-H
        ##                'ETenms-B5-H',      # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
        ##                                    # character set with ETen extensions; this uses proportional
        ##                                    # forms for half-width Latin characters.
        ##                'ETenms-B5-V',      # Vertical version of ETenms-B5-H
        ##                'CNS-EUC-H',        # CNS 11643-1992 character set, EUC-TW encoding
        ##                'CNS-EUC-V',        # Vertical version of CNS-EUC-H
        ##                'UniCNS-UCS2-H',    # Unicode (UCS-2) encoding for the Adobe-CNS1
        ##                                    # character collection
        ##                'UniCNS-UCS2-V'    # Vertical version of UniCNS-UCS2-H.
        ##                ]
        ##
        ##            The next 32 pages show the complete character set available in the encoding
        ##            "ETen-B5-H".  This is Big5 with the ETen extensions.  ETen extensions are the
        ##            most common extension to Big5 and include circled and roman numbers, Japanese
        ##            hiragana and katakana, Cyrillic and fractions in rows C6-C8; and 7 extra characters
        ##            and some line drawing characters in row F9.
        ##            """)
        ##        c.drawText(tx)
        ##        c.setFont('Helvetica',10)
        ##        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        ##
        ##        c.showPage()
        ##
        ##        # full Big5 code page
        ##        c.setFont('Helvetica', 18)
        ##        c.drawString(72,750, 'Characters available in Big 5')
        ##        y = 500
        ##        for row in range(0xA1,0xFF):
        ##            cc = Big5CodeChart(row, 'MSung-Light',enc)
        ##            cc.charsPerRow = 16
        ##            cc.rows = 10
        ##            cc.codePoints = 160
        ##            cc.drawOn(c, 72, y)
        ##            y = y - cc.height - 25
        ##            if y < 50:
        ##                c.setFont('Helvetica',10)
        ##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        ##                c.showPage()
        ##                y = 600
        ##
        ##
        c.save()
        if VERBOSE:
            print 'saved ' + outputfile('test_multibyte_cht.pdf')
Example #6
0
    def test0(self):

        # if they do not have the font files or encoding, go away quietly
        try:
            from reportlab.pdfbase.cidfonts import CIDFont, findCMapFile
            findCMapFile('KSCms-UHC-H')
        except:
            #don't have the font pack.  return silently
            return

        localFontName = 'HYSMyeongJo-Medium'
        c = Canvas(outputfile('test_multibyte_kor.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100,700, 'Korean Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample in Unified Hangul Coding (UHC)')

        hBoxText('\xB9\xD9\xC5\xC1\xC3\xBC  (HYSMyeongJo-Medium)',
                 c, 100, 660, 'HYSMyeongJo-Medium', 'KSCms-UHC-H')
##        hBoxText('\xB9\xD9\xC5\xC1\xC3\xBC  (HYGothic-Medium)',
##                 c, 100, 640, 'HYGothic-Medium', 'KSCms-UHC-H')

        pdfmetrics.registerFont(CIDFont('HYSMyeongJo-Medium','KSC-EUC-H'))
        c.setFont('Helvetica', 10)
        c.drawString(100,610, "Longer sample From Adobe's Acrobat web page in EUC:")

        sample = """\xbf\xad \xbc\xf6 \xbe\xf8\xb4\xc2 \xb9\xae\xbc\xad\xb4\xc2 \xbe\xc6\xb9\xab\xb7\xb1 \xbc\xd2\xbf\xeb\xc0\xcc \xbe\xf8\xbd\xc0\xb4\xcf\xb4\xd9. \xbb\xe7\xbe\xf7 \xb0\xe8\xc8\xb9\xbc\xad, \xbd\xba\xc7\xc1\xb7\xb9\xb5\xe5\xbd\xc3\xc6\xae, \xb1\xd7\xb7\xa1\xc7\xc8\xc0\xcc \xb8\xb9\xc0\xcc \xc6\xf7\xc7\xd4\xb5\xc8 \xbc\xd2\xc3\xa5\xc0\xda \xb6\xc7\xb4\xc2 \xc0\xa5
\xbb\xe7\xc0\xcc\xc6\xae\xb8\xa6 \xc0\xdb\xbc\xba\xc7\xcf\xb4\xc2 \xb0\xe6\xbf\xec Adobe\xa2\xe7 Acrobat\xa2\xe7 5.0 \xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee\xb8\xa6 \xbb\xe7\xbf\xeb\xc7\xd8\xbc\xad \xc7\xd8\xb4\xe7 \xb9\xae\xbc\xad\xb8\xa6 Adobe
Portable Document Format (PDF) \xc6\xc4\xc0\xcf\xb7\xce \xba\xaf\xc8\xaf\xc7\xd2 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9. \xb4\xa9\xb1\xb8\xb3\xaa \xb1\xa4\xb9\xfc\xc0\xa7\xc7\xd1 \xc1\xbe\xb7\xf9\xc0\xc7
\xc7\xcf\xb5\xe5\xbf\xfe\xbe\xee\xbf\xcd \xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee\xbf\xa1\xbc\xad \xb9\xae\xbc\xad\xb8\xa6 \xbf\xad \xbc\xf6 \xc0\xd6\xc0\xb8\xb8\xe7 \xb7\xb9\xc0\xcc\xbe\xc6\xbf\xf4, \xc6\xf9\xc6\xae, \xb8\xb5\xc5\xa9, \xc0\xcc\xb9\xcc\xc1\xf6 \xb5\xee\xc0\xbb \xbf\xf8\xba\xbb \xb1\xd7\xb4\xeb\xb7\xce \xc0\xc7\xb5\xb5\xc7\xd1 \xb9\xd9 \xb4\xeb\xb7\xce
\xc7\xa5\xbd\xc3\xc7\xd2 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9. Acrobat 5.0\xc0\xbb \xbb\xe7\xbf\xeb\xc7\xcf\xbf\xa9 \xc0\xa5 \xba\xea\xb6\xf3\xbf\xec\xc0\xfa\xbf\xa1\xbc\xad \xb9\xae\xbc\xad\xb8\xa6 \xbd\xc2\xc0\xce\xc7\xcf\xb0\xed \xc1\xd6\xbc\xae\xc0\xbb \xc3\xdf\xb0\xa1\xc7\xcf\xb4\xc2 \xb9\xe6\xbd\xc4\xc0\xb8\xb7\xce
\xb1\xe2\xbe\xf7\xc0\xc7 \xbb\xfd\xbb\xea\xbc\xba\xc0\xbb \xc7\xe2\xbb\xf3\xbd\xc3\xc5\xb3 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9.

\xc0\xfa\xc0\xdb\xb1\xc7 &copy; 2001 Adobe Systems Incorporated. \xb8\xf0\xb5\xe7 \xb1\xc7\xb8\xae\xb0\xa1 \xba\xb8\xc8\xa3\xb5\xcb\xb4\xcf\xb4\xd9.
\xbb\xe7\xbf\xeb\xc0\xda \xbe\xe0\xb0\xfc
\xbf\xc2\xb6\xf3\xc0\xce \xbb\xe7\xbf\xeb\xc0\xda \xba\xb8\xc8\xa3 \xb1\xd4\xc1\xa4
Adobe\xc0\xc7 \xc0\xe5\xbe\xd6\xc0\xda \xc1\xf6\xbf\xf8
\xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee \xba\xd2\xb9\xfd \xc0\xcc\xbf\xeb \xb9\xe6\xc1\xf6
"""
        tx = c.beginText(100,600)
        tx.setFont('HYSMyeongJo-Medium-KSC-EUC-H', 7, 8)
        tx.textLines(sample)
        tx.setFont('Helvetica', 10, 12)
        tx.textLine()
        tx.textLines("""This test document shows Korean output from the Reportlab PDF Library.
            You may use one Korean font, HYSMyeongJo-Medium, and a number of different
            encodings.

            The available encoding names (with comments from the PDF specification) are:
            encodings_kor = [
                'KSC-EUC-H',        # KS X 1001:1992 character set, EUC-KR encoding
                'KSC-EUC-V',        # Vertical version of KSC-EUC-H
                'KSCms-UHC-H',      # Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992
                                    #character set plus 8,822 additional hangul, Unified Hangul
                                    #Code (UHC) encoding
                'KSCms-UHC-V',      #Vertical version of KSCms-UHC-H
                'KSCms-UHC-HW-H',   #Same as KSCms-UHC-H, but replaces proportional Latin
                                    # characters with halfwidth forms
                'KSCms-UHC-HW-V',   #Vertical version of KSCms-UHC-HW-H
                'KSCpc-EUC-H',      #Macintosh, KS X 1001:1992 character set with MacOS-KH
                                    #extensions, Script Manager Code 3
                'UniKS-UCS2-H',     #Unicode (UCS-2) encoding for the Adobe-Korea1 character collection
                'UniKS-UCS2-V'      #Vertical version of UniKS-UCS2-H
                ]

            The following pages show all characters in the KS X 1001:1992 standard, using the
            encoding 'KSC-EUC-H' above.  More characters (a LOT more) are available if you
            use UHC encoding or the Korean Unicode subset, for which the correct encoding
            names are also listed above.
            """)

        c.drawText(tx)

        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        c.showPage()

        # full kuten chart in EUC
        c.setFont('Helvetica', 18)
        c.drawString(72,750, 'Characters available in KS X 1001:1992, EUC encoding')
        y = 600
        for row in range(1, 95):
            KutenRowCodeChart(row, 'HYSMyeongJo-Medium','KSC-EUC-H').drawOn(c, 72, y)
            y = y - 125
            if y < 50:
                c.setFont('Helvetica',10)
                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
                c.showPage()
                y = 700

        c.save()

        if VERBOSE:
            print 'saved '+outputfile('test_multibyte_kor.pdf')
Example #7
0
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import CIDFont, findCMapFile


        enc = 'ETenms-B5-H'
        try:
            findCMapFile(enc)
        except:
            #they don't have the font pack, return silently
            return
        pdfmetrics.registerFont(CIDFont('MSung-Light',enc))

        c = Canvas(outputfile('test_multibyte_cht.pdf'))
        c.setFont('Helvetica', 24)
        c.drawString(100,700, 'Traditional Chinese Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: headline from Yahoo Hong Kong, 20 Oct 2001')

        c.setFont('MSung-Light-' + enc, 12)
        # this came from Yahoo Hong Kong leading story today
        message1 = '\xa5\xac\xae\xed\xbbP\xa6\xbf\xbfA\xa5\xc1\xa6b\xad\xba\xa6\xb8\xb7|\xad\xb1\xab\xe1\xa4@\xa6P\xa8\xa3\xb0O\xaa\xcc\xa1A\xa5L\xbb\xa1\xa1A\xa8\xe2\xa4H\xaa\xba\xad\xba\xa6\xb8\xb7|\xad\xb1\xabD\xb1`'
        message2 = '\xa6n\xa1A\xa8\xc3\xaa\xed\xa5\xdc\xb2@\xb5L\xba\xc3\xb0\xdd\xa4\xa4\xb0\xea\xa6b\xb3o\xad\xd3\xa5i\xa9\xc6\xaa\xba\xae\xc9\xa8\xe8\xa1A\xb7|\xbbP\xac\xfc\xb0\xea\xa4H\xa5\xc1\xaf\xb8\xa6b\xa4@\xb0_\xa1C'
        message3 = '\xA7\x41\xA6\x6E\xB6\xDC'


        c.drawString(100, 655, message1)
        c.drawString(100, 639, message2)

        hBoxText(message3 + ' MSung-Light' , c, 100, 600, 'MSung-Light', enc)
        #hBoxText(message3 + ' MHei-Medium', c, 100, 580, 'MHei-Medium', enc)



        c.setFont('Helvetica', 10)
        tx = c.beginText(100, 500)
        tx.textLines("""
            This test document shows Traditional Chinese output from Reportlab PDF Library.
            You may use one Chinese font, MSung-Light, and a number of different
            encodings.

            The available encoding names (with comments from the PDF specification) are:
            encodings_cht = [
                'B5pc-H',           # Macintosh, Big Five character set, Big Five encoding,
                                    # Script Manager code 2
                'B5pc-V',           # Vertical version of B5pc-H
                'ETen-B5-H',        # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
                                    # character set with ETen extensions
                'ETen-B5-V',        # Vertical version of ETen-B5-H
                'ETenms-B5-H',      # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
                                    # character set with ETen extensions; this uses proportional
                                    # forms for half-width Latin characters.
                'ETenms-B5-V',      # Vertical version of ETenms-B5-H
                'CNS-EUC-H',        # CNS 11643-1992 character set, EUC-TW encoding
                'CNS-EUC-V',        # Vertical version of CNS-EUC-H
                'UniCNS-UCS2-H',    # Unicode (UCS-2) encoding for the Adobe-CNS1
                                    # character collection
                'UniCNS-UCS2-V'    # Vertical version of UniCNS-UCS2-H.
                ]

            The next 32 pages show the complete character set available in the encoding
            "ETen-B5-H".  This is Big5 with the ETen extensions.  ETen extensions are the
            most common extension to Big5 and include circled and roman numbers, Japanese
            hiragana and katakana, Cyrillic and fractions in rows C6-C8; and 7 extra characters
            and some line drawing characters in row F9.
            """)
        c.drawText(tx)
        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())

        c.showPage()

        # full Big5 code page
        c.setFont('Helvetica', 18)
        c.drawString(72,750, 'Characters available in Big 5')
        y = 500
        for row in range(0xA1,0xFF):
            cc = Big5CodeChart(row, 'MSung-Light',enc)
            cc.charsPerRow = 16
            cc.rows = 10
            cc.codePoints = 160
            cc.drawOn(c, 72, y)
            y = y - cc.height - 25
            if y < 50:
                c.setFont('Helvetica',10)
                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
                c.showPage()
                y = 600


        c.save()
        if VERBOSE:
            print 'saved '+outputfile('test_multibyte_cht.pdf')
Example #8
0
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile


##        enc = 'ETenms-B5-H'
##        try:
##            findCMapFile(enc)
##        except:
##            #they don't have the font pack, return silently
##            print 'CMap not found'
##            return
        pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))

        c = Canvas(outputfile('test_multibyte_cht.pdf'))
        c.setFont('Helvetica', 24)
        c.drawString(100,700, 'Traditional Chinese Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: "Taiwan  -  Ang Lee" (movie director)')

        hBoxText(u'\u81fa\u7063 - \u674e\u5b89' , c, 100, 600, 'MSung-Light')


##        #hBoxText(message3 + ' MHei-Medium', c, 100, 580, 'MHei-Medium', enc)
##
##
##
##        c.setFont('Helvetica', 10)
##        tx = c.beginText(100, 500)
##        tx.textLines("""
##            This test document shows Traditional Chinese output from Reportlab PDF Library.
##            You may use one Chinese font, MSung-Light, and a number of different
##            encodings.
##
##            The available encoding names (with comments from the PDF specification) are:
##            encodings_cht = [
##                'B5pc-H',           # Macintosh, Big Five character set, Big Five encoding,
##                                    # Script Manager code 2
##                'B5pc-V',           # Vertical version of B5pc-H
##                'ETen-B5-H',        # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
##                                    # character set with ETen extensions
##                'ETen-B5-V',        # Vertical version of ETen-B5-H
##                'ETenms-B5-H',      # Microsoft Code Page 950 (lfCharSet 0x88), Big Five
##                                    # character set with ETen extensions; this uses proportional
##                                    # forms for half-width Latin characters.
##                'ETenms-B5-V',      # Vertical version of ETenms-B5-H
##                'CNS-EUC-H',        # CNS 11643-1992 character set, EUC-TW encoding
##                'CNS-EUC-V',        # Vertical version of CNS-EUC-H
##                'UniCNS-UCS2-H',    # Unicode (UCS-2) encoding for the Adobe-CNS1
##                                    # character collection
##                'UniCNS-UCS2-V'    # Vertical version of UniCNS-UCS2-H.
##                ]
##
##            The next 32 pages show the complete character set available in the encoding
##            "ETen-B5-H".  This is Big5 with the ETen extensions.  ETen extensions are the
##            most common extension to Big5 and include circled and roman numbers, Japanese
##            hiragana and katakana, Cyrillic and fractions in rows C6-C8; and 7 extra characters
##            and some line drawing characters in row F9.
##            """)
##        c.drawText(tx)
##        c.setFont('Helvetica',10)
##        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
##
##        c.showPage()
##
##        # full Big5 code page
##        c.setFont('Helvetica', 18)
##        c.drawString(72,750, 'Characters available in Big 5')
##        y = 500
##        for row in range(0xA1,0xFF):
##            cc = Big5CodeChart(row, 'MSung-Light',enc)
##            cc.charsPerRow = 16
##            cc.rows = 10
##            cc.codePoints = 160
##            cc.drawOn(c, 72, y)
##            y = y - cc.height - 25
##            if y < 50:
##                c.setFont('Helvetica',10)
##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
##                c.showPage()
##                y = 600
##
##
        c.save()
        if VERBOSE:
            print('saved '+outputfile('test_multibyte_cht.pdf'))
Example #9
0
    def test0(self):
        "A basic document drawing some strings"

        # if they do not have the Japanese font files, go away quietly
        from reportlab.pdfbase.cidfonts import CIDFont, findCMapFile


        enc = 'GB-EUC-H'
        try:
            findCMapFile(enc)
        except:
            #they don't have the font pack, return silently
            return
        pdfmetrics.registerFont(CIDFont('STSong-Light',enc))

        c = Canvas(outputfile('test_multibyte_chs.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100,700, 'Simplified Chinese Font Support')


        c.setFont('Helvetica', 10)
        c.drawString(100,680, 'Short sample: "Reportlab is cool!" (or so we are told)')
        # the two typefaces

        hBoxText('\xce\xc4\xbd\xa1\xb5\xc3\xb5\xbd\xc1\xcb \xc4\xc7\xd5\xfd\xba\xc3\xb0\xa2  \xce\xd2 \xba\xdc\xcf\xb2\xbb\xb6. Cool!',
                 c,
                 100,
                 660,
                 'STSong-Light',
                 enc)


        c.setFont('Helvetica', 10)
        tx = c.beginText(100, 500)
        tx.textLines("""
            This test document shows Simplified Chinese output from the Reportlab PDF Library.
            You may use one Chinese font, STSong-Light, and a number of different encodings.

            The available encoding names (with comments from the PDF specification) are:
            encodings_chs = [
                'GB-EUC-H',         # Microsoft Code Page 936 (lfCharSet 0x86), GB 2312-80
                                    # character set, EUC-CN encoding
                'GB-EUC-V',         # Vertical version of GB-EUC-H
                'GBpc-EUC-H',       # Macintosh, GB 2312-80 character set, EUC-CN encoding,
                                    # Script Manager code 2
                'GBpc-EUC-V',       # Vertical version of GBpc-EUC-H
                'GBK-EUC-H',        # Microsoft Code Page 936 (lfCharSet 0x86), GBK character
                                    # set, GBK encoding
                'GBK-EUC-V',        # Vertical version of GBK-EUC-V
                'UniGB-UCS2-H',     # Unicode (UCS-2) encoding for the Adobe-GB1
                                    # character collection
                'UniGB-UCS2-V'     # Vertical version of UniGB-UCS2-H.
                ]

            The next few pages show the complete character set available in the encoding
            "GB-EUC-H".  This is the GB 2312-80 character set.
            """)
        c.drawText(tx)

        c.setFont('Helvetica',10)
        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        c.showPage()

        # full kuten chart in EUC
        c.setFont('Helvetica', 18)
        c.drawString(72,750, 'Characters available in GB 2312-80, EUC encoding')
        y = 600
        for row in range(1, 95):
            KutenRowCodeChart(row, 'STSong-Light',enc).drawOn(c, 72, y)
            y = y - 125
            if y < 50:
                c.setFont('Helvetica',10)
                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
                c.showPage()
                y = 700

        c.save()
        if VERBOSE:
            print 'saved '+outputfile('test_multibyte_chs.pdf')
    def test0(self):

        # if they do not have the font files or encoding, go away quietly
        ##        try:
        ##            from reportlab.pdfbase.cidfonts import CIDFont, findCMapFile
        ##            findCMapFile('KSCms-UHC-H')
        ##        except:
        ##            #don't have the font pack.  return silently
        ##            print 'CMap not found'
        ##            return

        localFontName = 'HYSMyeongJo-Medium'
        c = Canvas(outputfile('test_multibyte_kor.pdf'))
        c.setFont('Helvetica', 30)
        c.drawString(100, 700, 'Korean Font Support')
        c.setFont('Helvetica', 10)
        c.drawString(
            100, 680,
            'Short sample in Unicode; grey area should outline the text with correct width.'
        )

        hBoxText(u'\ub300\ud55c\ubbfc\uad6d = Korea', c, 100, 660,
                 'HYSMyeongJo-Medium')
        hBoxText(u'\uc548\uc131\uae30 = AHN Sung-Gi (Actor)', c, 100, 640,
                 'HYGothic-Medium')

        ##        pdfmetrics.registerFont(UnicodeCIDFont('HYSMyeongJo-Medium'))
        ##        c.setFont('Helvetica', 10)
        ##        c.drawString(100,610, "Longer sample From Adobe's Acrobat web page in EUC:")
        ##
        ##        sample = """\xbf\xad \xbc\xf6 \xbe\xf8\xb4\xc2 \xb9\xae\xbc\xad\xb4\xc2 \xbe\xc6\xb9\xab\xb7\xb1 \xbc\xd2\xbf\xeb\xc0\xcc \xbe\xf8\xbd\xc0\xb4\xcf\xb4\xd9. \xbb\xe7\xbe\xf7 \xb0\xe8\xc8\xb9\xbc\xad, \xbd\xba\xc7\xc1\xb7\xb9\xb5\xe5\xbd\xc3\xc6\xae, \xb1\xd7\xb7\xa1\xc7\xc8\xc0\xcc \xb8\xb9\xc0\xcc \xc6\xf7\xc7\xd4\xb5\xc8 \xbc\xd2\xc3\xa5\xc0\xda \xb6\xc7\xb4\xc2 \xc0\xa5
        ##\xbb\xe7\xc0\xcc\xc6\xae\xb8\xa6 \xc0\xdb\xbc\xba\xc7\xcf\xb4\xc2 \xb0\xe6\xbf\xec Adobe\xa2\xe7 Acrobat\xa2\xe7 5.0 \xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee\xb8\xa6 \xbb\xe7\xbf\xeb\xc7\xd8\xbc\xad \xc7\xd8\xb4\xe7 \xb9\xae\xbc\xad\xb8\xa6 Adobe
        ##Portable Document Format (PDF) \xc6\xc4\xc0\xcf\xb7\xce \xba\xaf\xc8\xaf\xc7\xd2 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9. \xb4\xa9\xb1\xb8\xb3\xaa \xb1\xa4\xb9\xfc\xc0\xa7\xc7\xd1 \xc1\xbe\xb7\xf9\xc0\xc7
        ##\xc7\xcf\xb5\xe5\xbf\xfe\xbe\xee\xbf\xcd \xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee\xbf\xa1\xbc\xad \xb9\xae\xbc\xad\xb8\xa6 \xbf\xad \xbc\xf6 \xc0\xd6\xc0\xb8\xb8\xe7 \xb7\xb9\xc0\xcc\xbe\xc6\xbf\xf4, \xc6\xf9\xc6\xae, \xb8\xb5\xc5\xa9, \xc0\xcc\xb9\xcc\xc1\xf6 \xb5\xee\xc0\xbb \xbf\xf8\xba\xbb \xb1\xd7\xb4\xeb\xb7\xce \xc0\xc7\xb5\xb5\xc7\xd1 \xb9\xd9 \xb4\xeb\xb7\xce
        ##\xc7\xa5\xbd\xc3\xc7\xd2 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9. Acrobat 5.0\xc0\xbb \xbb\xe7\xbf\xeb\xc7\xcf\xbf\xa9 \xc0\xa5 \xba\xea\xb6\xf3\xbf\xec\xc0\xfa\xbf\xa1\xbc\xad \xb9\xae\xbc\xad\xb8\xa6 \xbd\xc2\xc0\xce\xc7\xcf\xb0\xed \xc1\xd6\xbc\xae\xc0\xbb \xc3\xdf\xb0\xa1\xc7\xcf\xb4\xc2 \xb9\xe6\xbd\xc4\xc0\xb8\xb7\xce
        ##\xb1\xe2\xbe\xf7\xc0\xc7 \xbb\xfd\xbb\xea\xbc\xba\xc0\xbb \xc7\xe2\xbb\xf3\xbd\xc3\xc5\xb3 \xbc\xf6 \xc0\xd6\xbd\xc0\xb4\xcf\xb4\xd9.
        ##
        ##\xc0\xfa\xc0\xdb\xb1\xc7 &copy; 2001 Adobe Systems Incorporated. \xb8\xf0\xb5\xe7 \xb1\xc7\xb8\xae\xb0\xa1 \xba\xb8\xc8\xa3\xb5\xcb\xb4\xcf\xb4\xd9.
        ##\xbb\xe7\xbf\xeb\xc0\xda \xbe\xe0\xb0\xfc
        ##\xbf\xc2\xb6\xf3\xc0\xce \xbb\xe7\xbf\xeb\xc0\xda \xba\xb8\xc8\xa3 \xb1\xd4\xc1\xa4
        ##Adobe\xc0\xc7 \xc0\xe5\xbe\xd6\xc0\xda \xc1\xf6\xbf\xf8
        ##\xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee \xba\xd2\xb9\xfd \xc0\xcc\xbf\xeb \xb9\xe6\xc1\xf6
        ##"""
        ##        tx = c.beginText(100,600)
        ##        tx.setFont('HYSMyeongJo-Medium-KSC-EUC-H', 7, 8)
        ##        tx.textLines(sample)
        ##        tx.setFont('Helvetica', 10, 12)
        ##        tx.textLine()
        ##        tx.textLines("""This test document shows Korean output from the Reportlab PDF Library.
        ##            You may use one Korean font, HYSMyeongJo-Medium, and a number of different
        ##            encodings.
        ##
        ##            The available encoding names (with comments from the PDF specification) are:
        ##            encodings_kor = [
        ##                'KSC-EUC-H',        # KS X 1001:1992 character set, EUC-KR encoding
        ##                'KSC-EUC-V',        # Vertical version of KSC-EUC-H
        ##                'KSCms-UHC-H',      # Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992
        ##                                    #character set plus 8,822 additional hangul, Unified Hangul
        ##                                    #Code (UHC) encoding
        ##                'KSCms-UHC-V',      #Vertical version of KSCms-UHC-H
        ##                'KSCms-UHC-HW-H',   #Same as KSCms-UHC-H, but replaces proportional Latin
        ##                                    # characters with halfwidth forms
        ##                'KSCms-UHC-HW-V',   #Vertical version of KSCms-UHC-HW-H
        ##                'KSCpc-EUC-H',      #Macintosh, KS X 1001:1992 character set with MacOS-KH
        ##                                    #extensions, Script Manager Code 3
        ##                'UniKS-UCS2-H',     #Unicode (UCS-2) encoding for the Adobe-Korea1 character collection
        ##                'UniKS-UCS2-V'      #Vertical version of UniKS-UCS2-H
        ##                ]
        ##
        ##            The following pages show all characters in the KS X 1001:1992 standard, using the
        ##            encoding 'KSC-EUC-H' above.  More characters (a LOT more) are available if you
        ##            use UHC encoding or the Korean Unicode subset, for which the correct encoding
        ##            names are also listed above.
        ##            """)
        ##
        ##        c.drawText(tx)
        ##
        ##        c.setFont('Helvetica',10)
        ##        c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        ##        c.showPage()
        ##
        ##        # full kuten chart in EUC
        ##        c.setFont('Helvetica', 18)
        ##        c.drawString(72,750, 'Characters available in KS X 1001:1992, EUC encoding')
        ##        y = 600
        ##        for row in range(1, 95):
        ##            KutenRowCodeChart(row, 'HYSMyeongJo-Medium','KSC-EUC-H').drawOn(c, 72, y)
        ##            y = y - 125
        ##            if y < 50:
        ##                c.setFont('Helvetica',10)
        ##                c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber())
        ##                c.showPage()
        ##                y = 700

        c.save()

        if VERBOSE:
            print('saved ' + outputfile('test_multibyte_kor.pdf'))