author | andy_robinson |
Wed, 24 Jul 2002 19:56:39 +0000 | |
changeset 1683 | 7fa753e4420a |
parent 1679 | e77be1edcd61 |
child 2192 | 955d4bf3b9d2 |
permissions | -rw-r--r-- |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
1 |
#copyright ReportLab Inc. 2001 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
2 |
#see license.txt for license details |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
3 |
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/lib/codecharts?cvsroot=reportlab |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
4 |
#$Header $ |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
5 |
__version__=''' $Id ''' |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
6 |
__doc__="""Routines to print code page (character set) drawings. |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
7 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
8 |
To be sure we can accurately represent characters in various encodings |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
9 |
and fonts, we need some routines to display all those characters. |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
10 |
These are defined herein. The idea is to include flowable, drawable |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
11 |
and graphic objects for single and multi-byte fonts. """ |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
12 |
import string |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
13 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
14 |
from reportlab.pdfgen.canvas import Canvas |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
15 |
from reportlab.platypus import Flowable |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
16 |
from reportlab.pdfbase import pdfmetrics, cidfonts |
1679
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
17 |
from reportlab.graphics.shapes import Drawing, Group, String, Circle, Rect |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
18 |
from reportlab.graphics.widgetbase import Widget |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
19 |
from reportlab.lib import colors |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
20 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
21 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
22 |
class CodeChartBase(Flowable): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
23 |
"""Basic bits of drawing furniture used by |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
24 |
single and multi-byte versions: ability to put letters |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
25 |
into boxes.""" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
26 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
27 |
def calcLayout(self): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
28 |
"Work out x and y positions for drawing" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
29 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
30 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
31 |
rows = self.codePoints * 1.0 / self.charsPerRow |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
32 |
if rows == int(rows): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
33 |
self.rows = int(rows) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
34 |
else: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
35 |
self.rows = int(rows) + 1 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
36 |
# size allows for a gray column of labels |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
37 |
self.width = self.boxSize * (1+self.charsPerRow) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
38 |
self.height = self.boxSize * (1+self.rows) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
39 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
40 |
#handy lists |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
41 |
self.ylist = [] |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
42 |
for row in range(self.rows + 2): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
43 |
self.ylist.append(row * self.boxSize) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
44 |
self.xlist = [] |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
45 |
for col in range(self.charsPerRow + 2): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
46 |
self.xlist.append(col * self.boxSize) |
1683 | 47 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
48 |
def formatByte(self, byt): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
49 |
if self.hex: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
50 |
return '%02X' % byt |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
51 |
else: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
52 |
return '%d' % byt |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
53 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
54 |
def drawChars(self, charList): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
55 |
"""Fills boxes in order. None means skip a box. |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
56 |
Empty boxes at end get filled with gray""" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
57 |
extraNeeded = (self.rows * self.charsPerRow - len(charList)) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
58 |
charList = charList + [None] * extraNeeded |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
59 |
row = 0 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
60 |
col = 0 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
61 |
self.canv.setFont(self.fontName, self.boxSize * 0.75) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
62 |
for ch in charList: # may be 2 bytes or 1 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
63 |
if ch is None: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
64 |
self.canv.setFillGray(0.9) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
65 |
self.canv.rect((1+col) * self.boxSize, (self.rows - row - 1) * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
66 |
self.boxSize, self.boxSize, stroke=0, fill=1) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
67 |
self.canv.setFillGray(0.0) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
68 |
else: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
69 |
self.canv.drawCentredString( |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
70 |
(col+1.5) * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
71 |
(self.rows - row - 0.875) * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
72 |
ch |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
73 |
) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
74 |
col = col + 1 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
75 |
if col == self.charsPerRow: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
76 |
row = row + 1 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
77 |
col = 0 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
78 |
|
1362 | 79 |
def drawLabels(self, topLeft = ''): |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
80 |
"""Writes little labels in the top row and first column""" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
81 |
self.canv.setFillGray(0.8) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
82 |
self.canv.rect(0, self.ylist[-2], self.width, self.boxSize, fill=1, stroke=0) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
83 |
self.canv.rect(0, 0, self.boxSize, self.ylist[-2], fill=1, stroke=0) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
84 |
self.canv.setFillGray(0.0) |
1683 | 85 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
86 |
#label each row and column |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
87 |
self.canv.setFont('Helvetica-Oblique',0.375 * self.boxSize) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
88 |
byt = 0 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
89 |
for row in range(self.rows): |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
90 |
if self.rowLabels: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
91 |
label = self.rowLabels[row] |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
92 |
else: # format start bytes as hex or decimal |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
93 |
label = self.formatByte(row * self.charsPerRow) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
94 |
self.canv.drawCentredString(0.5 * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
95 |
(self.rows - row - 0.75) * self.boxSize, |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
96 |
label |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
97 |
) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
98 |
for col in range(self.charsPerRow): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
99 |
self.canv.drawCentredString((col + 1.5) * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
100 |
(self.rows + 0.25) * self.boxSize, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
101 |
self.formatByte(col) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
102 |
) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
103 |
|
1362 | 104 |
if topLeft: |
105 |
self.canv.setFont('Helvetica-BoldOblique',0.5 * self.boxSize) |
|
106 |
self.canv.drawCentredString(0.5 * self.boxSize, |
|
107 |
(self.rows + 0.25) * self.boxSize, |
|
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
108 |
topLeft |
1362 | 109 |
) |
1683 | 110 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
111 |
class SingleByteEncodingChart(CodeChartBase): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
112 |
def __init__(self, faceName='Helvetica', encodingName='WinAnsiEncoding', |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
113 |
charsPerRow=16, boxSize=14, hex=1): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
114 |
self.codePoints = 256 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
115 |
self.faceName = faceName |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
116 |
self.encodingName = encodingName |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
117 |
self.fontName = self.faceName + '-' + self.encodingName |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
118 |
self.charsPerRow = charsPerRow |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
119 |
self.boxSize = boxSize |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
120 |
self.hex = hex |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
121 |
self.rowLabels = None |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
122 |
pdfmetrics.registerFont(pdfmetrics.Font(self.fontName, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
123 |
self.faceName, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
124 |
self.encodingName) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
125 |
) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
126 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
127 |
self.calcLayout() |
1683 | 128 |
|
129 |
||
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
130 |
def draw(self): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
131 |
self.drawLabels() |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
132 |
charList = [None] * 32 + map(chr, range(32, 256)) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
133 |
self.drawChars(charList) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
134 |
self.canv.grid(self.xlist, self.ylist) |
1683 | 135 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
136 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
137 |
class KutenRowCodeChart(CodeChartBase): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
138 |
"""Formats one 'row' of the 94x94 space used in many Asian encodings.aliases |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
139 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
140 |
These deliberately resemble the code charts in Ken Lunde's "Understanding |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
141 |
CJKV Information Processing", to enable manual checking. Due to the large |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
142 |
numbers of characters, we don't try to make one graphic with 10,000 characters, |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
143 |
but rather output a sequence of these.""" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
144 |
#would be cleaner if both shared one base class whose job |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
145 |
#was to draw the boxes, but never mind... |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
146 |
def __init__(self, row, faceName, encodingName): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
147 |
self.row = row |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
148 |
self.codePoints = 94 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
149 |
self.boxSize = 18 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
150 |
self.charsPerRow = 20 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
151 |
self.rows = 5 |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
152 |
self.rowLabels = ['00','20','40','60','80'] |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
153 |
self.hex = 0 |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
154 |
self.faceName = faceName |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
155 |
self.encodingName = encodingName |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
156 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
157 |
try: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
158 |
# the dependent files might not be available |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
159 |
font = cidfonts.CIDFont(self.faceName, self.encodingName) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
160 |
pdfmetrics.registerFont(font) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
161 |
except: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
162 |
# fall back to English and at least shwo we can draw the boxes |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
163 |
self.faceName = 'Helvetica' |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
164 |
self.encodingName = 'WinAnsiEncoding' |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
165 |
self.fontName = self.faceName + '-' + self.encodingName |
1683 | 166 |
self.calcLayout() |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
167 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
168 |
def makeRow(self, row): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
169 |
"""Works out the character values for this kuten row""" |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
170 |
cells = [] |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
171 |
if string.find(self.encodingName, 'EUC') > -1: |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
172 |
# it is an EUC family encoding. |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
173 |
for col in range(1, 95): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
174 |
ch = chr(row + 160) + chr(col+160) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
175 |
cells.append(ch) |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
176 |
## elif string.find(self.encodingName, 'GB') > -1: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
177 |
## # it is an EUC family encoding. |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
178 |
## for col in range(1, 95): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
179 |
## ch = chr(row + 160) + chr(col+160) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
180 |
else: |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
181 |
cells.append([None] * 94) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
182 |
return cells |
1683 | 183 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
184 |
def draw(self): |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
185 |
self.drawLabels(topLeft= 'R%d' % self.row) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
186 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
187 |
# work out which characters we need for the row |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
188 |
#assert string.find(self.encodingName, 'EUC') > -1, 'Only handles EUC encoding today, you gave me %s!' % self.encodingName |
1683 | 189 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
190 |
# pad out by 1 to match Ken Lunde's tables |
1683 | 191 |
charList = [None] + self.makeRow(self.row) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
192 |
self.drawChars(charList) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
193 |
self.canv.grid(self.xlist, self.ylist) |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
194 |
|
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
195 |
|
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
196 |
class Big5CodeChart(CodeChartBase): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
197 |
"""Formats one 'row' of the 94x160 space used in Big 5 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
198 |
|
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
199 |
These deliberately resemble the code charts in Ken Lunde's "Understanding |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
200 |
CJKV Information Processing", to enable manual checking.""" |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
201 |
def __init__(self, row, faceName, encodingName): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
202 |
self.row = row |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
203 |
self.codePoints = 160 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
204 |
self.boxSize = 18 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
205 |
self.charsPerRow = 16 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
206 |
self.rows = 10 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
207 |
self.hex = 1 |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
208 |
self.faceName = faceName |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
209 |
self.encodingName = encodingName |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
210 |
self.rowLabels = ['4','5','6','7','A','B','C','D','E','F'] |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
211 |
try: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
212 |
# the dependent files might not be available |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
213 |
font = cidfonts.CIDFont(self.faceName, self.encodingName) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
214 |
pdfmetrics.registerFont(font) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
215 |
except: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
216 |
# fall back to English and at least shwo we can draw the boxes |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
217 |
self.faceName = 'Helvetica' |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
218 |
self.encodingName = 'WinAnsiEncoding' |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
219 |
self.fontName = self.faceName + '-' + self.encodingName |
1683 | 220 |
self.calcLayout() |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
221 |
|
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
222 |
def makeRow(self, row): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
223 |
"""Works out the character values for this Big5 row. |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
224 |
Rows start at 0xA1""" |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
225 |
cells = [] |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
226 |
if string.find(self.encodingName, 'B5') > -1: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
227 |
# big 5, different row size |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
228 |
for y in [4,5,6,7,10,11,12,13,14,15]: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
229 |
for x in range(16): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
230 |
col = y*16+x |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
231 |
ch = chr(row) + chr(col) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
232 |
cells.append(ch) |
1683 | 233 |
|
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
234 |
else: |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
235 |
cells.append([None] * 160) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
236 |
return cells |
1683 | 237 |
|
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
238 |
def draw(self): |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
239 |
self.drawLabels(topLeft='%02X' % self.row) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
240 |
|
1683 | 241 |
charList = self.makeRow(self.row) |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
242 |
self.drawChars(charList) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
243 |
self.canv.grid(self.xlist, self.ylist) |
1378
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
244 |
|
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
245 |
|
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
246 |
def hBoxText(msg, canvas, x, y, faceName, encName): |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
247 |
"""Helper for stringwidth tests on Asian fonts. |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
248 |
|
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
249 |
Registers font if needed. Then draws the string, |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
250 |
and a box around it derived from the stringWidth function""" |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
251 |
canvas.saveState() |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
252 |
fontName = faceName + '-' + encName |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
253 |
try: |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
254 |
font = pdfmetrics.getFont(fontName) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
255 |
except KeyError: |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
256 |
font = cidfonts.CIDFont(faceName, encName) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
257 |
pdfmetrics.registerFont(font) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
258 |
|
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
259 |
canvas.setFillGray(0.8) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
260 |
canvas.rect(x,y,pdfmetrics.stringWidth(msg, fontName, 16),16,stroke=0,fill=1) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
261 |
canvas.setFillGray(0) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
262 |
canvas.setFont(fontName, 16,16) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
263 |
canvas.drawString(x,y,msg) |
796ce78d458a
Fixed font registry entries, tidied up stringWidth tests
andy_robinson
parents:
1363
diff
changeset
|
264 |
canvas.restoreState() |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
265 |
|
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
266 |
|
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
267 |
class CodeWidget(Widget): |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
268 |
"""Block showing all the characters""" |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
269 |
def __init__(self): |
1679
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
270 |
self.x = 0 |
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
271 |
self.y = 0 |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
272 |
self.width = 160 |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
273 |
self.height = 160 |
1683 | 274 |
|
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
275 |
def draw(self): |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
276 |
dx = self.width / 16.0 |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
277 |
dy = self.height / 16.0 |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
278 |
g = Group() |
1679
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
279 |
g.add(Rect(self.x, self.y, self.width, self.height, |
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
280 |
fillColor=None, strokeColor=colors.black)) |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
281 |
for x in range(16): |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
282 |
for y in range(16): |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
283 |
charValue = y * 16 + x |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
284 |
if charValue > 32: |
1679
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
285 |
s = String(self.x + x * dx, |
e77be1edcd61
Fixed page stream filter order (Thanks Bernhard)
andy_robinson
parents:
1675
diff
changeset
|
286 |
self.y + (self.height - y*dy), chr(charValue)) |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
287 |
g.add(s) |
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
288 |
return g |
1683 | 289 |
|
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
290 |
|
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
291 |
|
1683 | 292 |
|
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
293 |
|
1683 | 294 |
|
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
295 |
def test(): |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
296 |
c = Canvas('codecharts.pdf') |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
297 |
c.setFont('Helvetica-Bold', 24) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
298 |
c.drawString(72, 750, 'Testing code page charts') |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
299 |
cc1 = SingleByteEncodingChart() |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
300 |
cc1.drawOn(c, 72, 500) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
301 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
302 |
cc2 = SingleByteEncodingChart(charsPerRow=32) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
303 |
cc2.drawOn(c, 72, 300) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
304 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
305 |
cc3 = SingleByteEncodingChart(charsPerRow=25, hex=0) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
306 |
cc3.drawOn(c, 72, 100) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
307 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
308 |
c.showPage() |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
309 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
310 |
c.setFont('Helvetica-Bold', 24) |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
311 |
c.drawString(72, 750, 'Multi-byte Kuten code chart examples') |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
312 |
KutenRowCodeChart(1, 'HeiseiMin-W3','EUC-H').drawOn(c, 72, 600) |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
313 |
KutenRowCodeChart(16, 'HeiseiMin-W3','EUC-H').drawOn(c, 72, 450) |
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
314 |
KutenRowCodeChart(84, 'HeiseiMin-W3','EUC-H').drawOn(c, 72, 300) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
315 |
|
1363
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
316 |
c.showPage() |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
317 |
c.setFont('Helvetica-Bold', 24) |
92e3fb40a784
Asian fonts now all working in major encodings, and partly documented
andy_robinson
parents:
1362
diff
changeset
|
318 |
c.drawString(72, 750, 'Big5 Code Chart Examples') |
1675
92d3b3c2397d
Fixed standard fonts demo, added a basic code page graphic
andy_robinson
parents:
1378
diff
changeset
|
319 |
#Big5CodeChart(0xA1, 'MSungStd-Light-Acro','ETenms-B5-H').drawOn(c, 72, 500) |
1361
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
320 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
321 |
c.save() |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
322 |
print 'saved codecharts.pdf' |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
323 |
|
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
324 |
if __name__=='__main__': |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
325 |
test() |
35586d769319
Enhancements/fixes to Asian fonts; codecharts utility to
andy_robinson
parents:
diff
changeset
|
326 |
|
1683 | 327 |