File: escape-sequence.html

package info (click to toggle)
python-pychart 1.39-7.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,840 kB
  • ctags: 1,836
  • sloc: python: 6,899; makefile: 81; sh: 30
file content (306 lines) | stat: -rw-r--r-- 9,634 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><style type="text/css">
pre {background-color: #e0e0e0}
</style>

<link rel="STYLESHEET" href="pychart.css" type='text/css' />
<link rel="first" href="pychart.html" title='PyChart' />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="node29.html" />
<link rel="prev" href="module-font.html" />
<link rel="parent" href="module-font.html" />
<link rel="next" href="node29.html" />
<meta name='aesop' content='information' />
<title>17.1 Escape sequences</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="17 Drawing texts"
  href="module-font.html"><img src='previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="17 Drawing texts"
  href="module-font.html"><img src='up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="17.2 Procedures provided in"
  href="node29.html"><img src='next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">PyChart</td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-font.html">17 Drawing texts</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-font.html">17 Drawing texts</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="node29.html">17.2 Procedures provided in</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION0001710000000000000000"></A><A NAME="escape-sequence"></A><a id='l2h-290' xml:id='l2h-290'></a>
<BR>
17.1 Escape sequences
</H2>

<P>
A text string may contain escape characters that control its
appearance.  The escape sequences all start with the letter
``<code>/</code>''. Thus, to display ``<code>/</code>'' itself, you must write
``<code>//</code>''.

<P>
<BLOCKQUOTE>
<b>Restrictions</b>: <code>/h</code>, <code>/v</code>, and <code>/a</code> <em>must</em>
appear in the beginning of a string.

</BLOCKQUOTE>

<P>
<a id='l2h-293' xml:id='l2h-293'></a>

<P>
<a id='l2h-294' xml:id='l2h-294'></a>

<P>
<DL>
<DT><STRONG><code>/a<var>dd</var></code></STRONG></DT>
<DD>Specifies the angle of the text.  Parameter <var>dd</var> is a number
between -360 to 360.  Value 0 means left-to-right text, 90 means
bottom-to-up, etc.
If you want to print numbers right after an angle specification, put
<code>{</code> between the angle and the number. For example, the below
code shows string "<code>"100"</code>" at a 60-degree angle.

<P>
<div class="verbatim"><pre>
"/a60{}100"
</pre></div>
<a id='l2h-295' xml:id='l2h-295'></a>

<P>
</DD>
<DT><STRONG><code>/h</code><var>A</var>:</STRONG></DT>
<DD>Specifies horizontal alignment of the text.  <var>A</var> is one of
"<code>L</code>" (left alignment), "<code>R</code>" (right alignment), or "<code>C</code>"
(center alignment).

<P>
</DD>
<DT><STRONG><code>/v</code><var>A</var>:</STRONG></DT>
<DD>Specifies vertical alignment of the text.  <var>A</var> is one of "<code>B</code>"
(bottom), "<code>T</code>" (top), or "<code>M</code>" (middle).

<P>
</DD>
<DT><STRONG><code>/T</code></STRONG></DT>
<DD>:
Switch to Times font family.
<a id='l2h-296' xml:id='l2h-296'></a>

<P>
</DD>
<DT><STRONG><code>/H</code>:</STRONG></DT>
<DD>Switch to Helvetica font family.
<a id='l2h-297' xml:id='l2h-297'></a>
</DD>
<DT><STRONG><code>/C</code>:</STRONG></DT>
<DD>Switch to Courier font family.
<a id='l2h-298' xml:id='l2h-298'></a>
</DD>
<DT><STRONG><code>/B</code>:</STRONG></DT>
<DD>Switch to Bookman-Demi font family.
<a id='l2h-299' xml:id='l2h-299'></a>
</DD>
<DT><STRONG><code>/A</code>:</STRONG></DT>
<DD>Switch to AvantGarde-Book font family.
<a id='l2h-300' xml:id='l2h-300'></a>
</DD>
<DT><STRONG><code>/P</code>:</STRONG></DT>
<DD>Switch to Palatino font family.
<a id='l2h-301' xml:id='l2h-301'></a>
</DD>
<DT><STRONG><code>/S</code>:</STRONG></DT>
<DD>Switch to Symbol font family.
<a id='l2h-302' xml:id='l2h-302'></a>
</DD>
<DT><STRONG><code>/F{<var>family</var>}</code>:</STRONG></DT>
<DD>Switch to <var>family</var> font family.
The below example draws string "Funny" using ZapfDingbat font
(which produces some meaningless output).
<a id='l2h-303' xml:id='l2h-303'></a>

<P>
<div class="verbatim"><pre>
<a href="module-canvas.html">canvas.</a>show(100, 200, "/F{ZapfDingbat}Funny")
</pre></div>

<P>
The list of available fonts are the following:

<P>
<BLOCKQUOTE>
Bookman-Demi Bookman-Light Courier AvantGarde-Book AvantGarde-Demi
Helvetica Helvetica-Narrow Palatino NewCenturySchlbk Times
Symbol ZapfChancery-MediumItalic ZapfChancery-Medium-Italic ZapfDingbats

</BLOCKQUOTE>

<P>
</DD>
<DT><STRONG><code>/b</code>:</STRONG></DT>
<DD>Switch to bold typeface.
<a id='l2h-304' xml:id='l2h-304'></a>
</DD>
<DT><STRONG><code>/i</code>:</STRONG></DT>
<DD>Switch to italic typeface.
<a id='l2h-305' xml:id='l2h-305'></a>
</DD>
<DT><STRONG><code>/o</code>:</STRONG></DT>
<DD>Switch to oblique typeface.
<a id='l2h-306' xml:id='l2h-306'></a>
</DD>
<DT><STRONG><code>/</code><var>dd</var>:</STRONG></DT>
<DD>Set font size to <var>dd</var> points.
<a id='l2h-291' xml:id='l2h-291'></a><a id='l2h-307' xml:id='l2h-307'></a>

<P>
<div class="verbatim"><pre>
"/20{}2001 space odyssey!"
</pre></div>

<P>
</DD>
<DT><STRONG><code>/c</code><var>dd</var>:</STRONG></DT>
<DD>Set gray-scale to 0.<var>dd</var>.
Gray-scale of 0 means black, 1 means white.
<a id='l2h-292' xml:id='l2h-292'></a>
<P>
</DD>
<DT><STRONG><code>//</code>, <code>/{</code>, <code>/}</code>:</STRONG></DT>
<DD>Display `/', `}', or `{'.
</DD>
<DT><STRONG><code>{ ... }</code>:</STRONG></DT>
<DD>Limit the scope of escape sequences. For example,
<code>"{/10{/20Big text} and small text}"</code>
will display <code>"Big Text"</code> using
a 20-point font, and <code>"and small text"</code> using a 10-point font.
<a id='l2h-308' xml:id='l2h-308'></a>

<P>
</DD>
<DT><STRONG><code><SPAN CLASS="MATH"><IMG
 WIDTH="12" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
 SRC="img1.png"
 ALT="$\backslash$"></SPAN>n</code>:</STRONG></DT>
<DD>Break the line.
<a id='l2h-309' xml:id='l2h-309'></a>
</DD>
</DL>

<P>
<IMG
  WIDTH="944" HEIGHT="614" ALIGN="BOTTOM" BORDER="0"
 SRC="./fonttest.png"
 ALT="Image fonttest">

<P>
<b>  Font usage example </b>

<P>
Below is the source code that produces the above chart.
../demos/fonttest.py

<P>
<div class="verbatim"><pre>
from pychart import *
can = <a href="module-canvas.html">canvas.</a>default_canvas()
x, y = (100, 500)

def show_text(str):
    global x, y
    can.show(x, y, str)
    can.show(x + 200, y, "/12/C" + font.quotemeta(str))
    y -= 20

show_text("/12/hLLeft align")
show_text("/12/hRRight align")
show_text("/12/hCCenter align")
show_text("/a20/12/hRAngled text")

def show_textv(str):
    global x, y
    can.show(x, y, str)
    x += 150

y -= 40
x = 100
show_textv("/12/vT//12//vTTop align")
show_textv("/12/vM//12//vT/12Middle align")
show_textv("/12/vB//12//vT/12Bottom align")

y -= 40
x = 100
show_text("/16/HHelvetica")
show_text("/12/CCourier")
show_text("/12/NHelvetica-Narrow")
show_text("/12/PPalatino-Roman")
show_text("/12/AAvantgarde")
show_text("/12/T/iTimes-Italic")
show_text("/12/F{ZapfDingbats}ZapfDingbats")
</pre></div>

<P>

<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="17 Drawing texts"
  href="module-font.html"><img src='previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="17 Drawing texts"
  href="module-font.html"><img src='up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="17.2 Procedures provided in"
  href="node29.html"><img src='next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">PyChart</td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-font.html">17 Drawing texts</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-font.html">17 Drawing texts</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="node29.html">17.2 Procedures provided in</A>
</div>
</div>
<hr />
<span class="release-info">Documentation released on July 2, 2005.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>