author | robin <robin@reportlab.com> |
Tue, 07 Mar 2017 10:00:34 +0000 | |
changeset 4330 | 617ffa6bbdc8 |
parent 4252 | fe660f227cac |
permissions | -rw-r--r-- |
4330 | 1 |
#Copyright ReportLab Europe Ltd. 2000-2017 |
2963 | 2 |
#see license.txt for license details |
3 |
#history www.reportlab.co.uk/rl-cgi/viewcvs.cgi/rlextra/rlj/jpsupport.py |
|
4 |
# Temporary japanese support for ReportLab. |
|
5 |
""" |
|
6 |
The code in this module will disappear any day now and be replaced |
|
7 |
by classes in reportlab.pdfbase.cidfonts |
|
8 |
""" |
|
2984 | 9 |
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation |
10 |
setOutDir(__name__) |
|
2963 | 11 |
import string, os |
12 |
import codecs |
|
2966 | 13 |
import unittest |
2963 | 14 |
from reportlab.pdfbase import pdfmetrics |
15 |
from reportlab.pdfgen.canvas import Canvas |
|
16 |
from reportlab.lib import colors |
|
17 |
from reportlab.lib.codecharts import KutenRowCodeChart, hBoxText |
|
18 |
||
19 |
global VERBOSE |
|
20 |
VERBOSE = 0 |
|
21 |
||
22 |
class CHSFontTests(unittest.TestCase): |
|
23 |
||
24 |
def test0(self): |
|
25 |
"A basic document drawing some strings" |
|
26 |
||
27 |
# if they do not have the Japanese font files, go away quietly |
|
28 |
from reportlab.pdfbase.cidfonts import UnicodeCIDFont, findCMapFile |
|
29 |
||
30 |
||
31 |
pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light')) |
|
32 |
||
33 |
c = Canvas(outputfile('test_multibyte_chs.pdf')) |
|
34 |
c.setFont('Helvetica', 30) |
|
35 |
c.drawString(100,700, 'Simplified Chinese Font Support') |
|
36 |
||
37 |
||
38 |
c.setFont('Helvetica', 10) |
|
39 |
c.drawString(100,680, 'Short sample: "China - Zhang Ziyi" (famous actress)') |
|
40 |
# the two typefaces |
|
41 |
||
3922
fc4cfd77129f
test_multibyte_chs/cht/jpn/kor.py: fix tests for python 2
robin
parents:
3721
diff
changeset
|
42 |
hBoxText(u'\u4e2d\u56fd - \u7ae0\u5b50\u6021', |
2963 | 43 |
c, |
44 |
100, |
|
45 |
660, |
|
46 |
'STSong-Light', |
|
47 |
) |
|
48 |
||
49 |
||
50 |
c.setFont('Helvetica',10) |
|
51 |
c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber()) |
|
52 |
c.showPage() |
|
53 |
||
54 |
## # full kuten chart in EUC |
|
55 |
## c.setFont('Helvetica', 18) |
|
56 |
## c.drawString(72,750, 'Characters available in GB 2312-80, EUC encoding') |
|
57 |
## y = 600 |
|
58 |
## enc = 'GB_EUC_H' |
|
59 |
## for row in range(1, 95): |
|
60 |
## KutenRowCodeChart(row, 'STSong-Light',enc).drawOn(c, 72, y) |
|
61 |
## y = y - 125 |
|
62 |
## if y < 50: |
|
63 |
## c.setFont('Helvetica',10) |
|
64 |
## c.drawCentredString(297, 36, 'Page %d' % c.getPageNumber()) |
|
65 |
## c.showPage() |
|
66 |
## y = 700 |
|
67 |
## |
|
68 |
c.save() |
|
69 |
if VERBOSE: |
|
3721 | 70 |
print('saved '+outputfile('test_multibyte_chs.pdf')) |
2963 | 71 |
|
72 |
||
73 |
def makeSuite(): |
|
74 |
return makeSuiteForClasses(CHSFontTests) |
|
75 |
||
76 |
||
77 |
#noruntests |
|
78 |
if __name__ == "__main__": |
|
79 |
VERBOSE = 1 |
|
80 |
unittest.TextTestRunner().run(makeSuite()) |
|
81 |
printLocation() |