Debian Codegraph @

texmf-dist/doc/generic/pst-text/pst-text-doc.tex

raw
1 %% $Id: pst-text-doc.tex 887 2018-12-29 13:17:59Z herbert $
2 \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,
3 headings=small, headinclude=false,footinclude=false,oneside,abstract=on]{pst-doc}
4 \usepackage{pst-plot,pst-grad,pst-text}
5 \let\pstTextFV\fileversion
6 \usepackage{dtk-logos}
7
8
9 \renewcommand\bgImage{%
10 \begin{pspicture}(10,5)
11 \psWarp[fillcolor=red!40,fontsize=0.5cm,font=Times-Roman]{Some Text manipulations}%
12 \end{pspicture}%
13 }
14
15 \addbibresource{\jobname.bib}
16
17
18 \begin{document}
19
20 \title{\texttt{pst-text}}
21 \subtitle{Manipulate text and characters; v.\pstTextFV}
22 \author{Timothy Van Zandt\\Herbert Voß}
23 \docauthor{Herbert Voß}
24 \date{\today}
25 \maketitle
26
27 \tableofcontents
28
29 \clearpage%
30
31 \begin{abstract}
32 In general \PS does not know lines in the proper meaning of the word, but only
33 paths\index{path} and those can have any arbitrary form. Along such paths
34 arbitrary text may be arranged. The package
35 \LPack{pst-text} supports the setting of text along a path
36 and other character manipulations, where several characters
37 naturally result in a text again of course.
38
39 It should be noted that the correct result is not guaranteed with every \Lprog{dvips} driver.
40 This package was written for Rokicki's\index{Rokicki}
41 \Lprog{dvips} programme, which is practically part of every \TeX{}
42 distribution.
43
44 \vfill
45 Thanks to: Lars Kotthoff, Geoff Mercer
46 \end{abstract}
47
48 \clearpage
49
50 % ---------------------------------------------------------------------------------------
51 \section{Text manipulations}\label{sec:psttext:Textmanipulationen}
52 % ---------------------------------------------------------------------------------------
53 The package \LPack{pst-text} defines only one macro for text manipulations.
54 \begin{BDef}
55 \Lcs{pstextpath}\OptArg{\Largr{x,y}}\Largb{Graphic object}\Largb{Text}
56 \end{BDef}
57
58 \begin{description}
59 \item[\texttt{position}] specifies the alignment of the text referring to the path.
60 \begin{description}
61 \item[\texttt{l}] text starts at the beginning of the path (default).
62 \item[\texttt{c}] text is aligned symmetrically to the middle of the path.
63 \item[\texttt{r}] text ends at the end of the path.
64 \end{description}
65 As a basic principle it is to be kept in mind that when the text is longer
66 than the path this option has no effect since the path is filled with text
67 and any overflowing text disappears.
68 \item[(x,y)] is an offset\index{offset} and denotes the values by which the
69 particular characters shall be translated in $x$ and $y$ direction
70 relative to the path.
71 \verb+(x,y)+ have to be cartesian coordinates as the support for special
72 coordinates allowed by \PST is not
73 possible here. The dimensions of $x$ and $y$ refer to the current scale. The default is
74 \verb+(0,\TPoffset)+, where \Ldim{TPoffset} is set to a length of \verb+-0.7ex+.
75 \item[Graphic object] any arbitrary object which creates a path.
76 \item[Text] the text to set, which may only consist of alphanumeric
77 characters. No macros are possible within the text,
78 but the text may be put into a \Lcs{parbox}.
79 \end{description}
80
81 \PS does not reserve any space for the output, so that the current text
82 is overwritten if corresponding white space has not been provided by \TeX.
83 This can be achieved with a vertical feed (\Lcs{vspace}) or with a \Lenv{pspicture} environment.
84
85 \begin{minipage}{4.5cm}
86 \begin{pspicture}(-2,-2.5)(2,2.5)
87 \psset{linewidth=0.2pt}
88 \pstextpath[c](0,0){\pscircle{2}}%
89 {\Large Now just text is written in a circle.}
90 \end{pspicture}
91 \end{minipage}\hfill%
92 \begin{minipage}{\linewidth-4.5cm-1em}
93 \begin{lstlisting}
94 \begin{pspicture}(-2,-2.5)(2,2.5)
95 \psset{linewidth=0.2pt}
96 \pstextpath[c](0,0){\pscircle{2}}%
97 {\Large Now just text is written in a circle.}
98 \end{pspicture}
99 \end{lstlisting}
100 \end{minipage}
101
102 This first example shows the relatively easy use of the macro. If the path
103 is not required to be drawn the line style\index{line style} can be set to \Lkeyval{none}.
104 The following example shows the use of the offset option. It is clear that
105 every single character is translated, because the beginning and the end of the
106 text stayed the same. Since the text was written in a circle, a positive
107 specification for \verb+TPoffset+ causes a translation towards the centre of the circle.
108
109 \medskip\noindent
110 \begin{LTXexample}[width=4.5cm,pos=l]
111 \begin{pspicture}(-2,-2.5)(2,2.5)
112 \psset{linewidth=0.2pt}
113 \pstextpath[c](0,2ex){\pscircle{2}}%
114 {\Large Now just text is written in a circle.}
115 \end{pspicture}
116 \end{LTXexample}
117
118 % ---------------------------------------------------------------------------------------
119 \subsection{Examples}
120 % ---------------------------------------------------------------------------------------
121 With \Lcs{pscustom} one is offered unlimited
122 possibilities for paths. The following example uses the circle again, but
123 forms an eight, which is composed of four circle parts to get a continuous path. In
124 the second example a square has been appended to a circle. The starting point of the
125 path is always the circle at $0$, here marked by $\Rightarrow$.
126
127
128 \medskip\noindent
129 \begin{LTXexample}[width=4cm,pos=l]
130 \psset{unit=0.75,linestyle=none}
131 \begin{pspicture}(-2,-4)(2,4)
132 \pstextpath[l](0,0){%
133 \pscustom{
134 \psarcn(0,2){2}{0}{-90}
135 \psarc(0,-2){2}{90}{0}
136 \psarc(0,-2){2}{0}{90}
137 \psarcn(0,2){2}{-90}{0}
138 }%
139 }{\large $\Rightarrow$Now we are writing some nonsense text which appears in
140 a large eight in the correct direction.}
141 \end{pspicture}
142 \end{LTXexample}
143
144 \medskip\noindent
145 It can be easily seen that in the above example the upper circle is larger than
146 the lower. This is because the text is always written on the path, which faces
147 towards the inner on the upper circle and towards the outer on the lower circle (or square)
148 due to the
149 change in direction.
150
151
152 \medskip\noindent
153 \begin{LTXexample}[width=4cm,pos=l]
154 \begin{pspicture}(-2,-3.25)(2,3.25)
155 \psset{linestyle=none}
156 \pstextpath[l](0,0){%
157 \pscustom[unit=0.75]{
158 \psarcn(0,2){2}{0}{-90}
159 \pspolygon(0,0)(-1.7,0)(-1.7,-3.4)(1.7,-3.4)(1.7,0)(0,0)
160 \psarcn(0,2){2}{-90}{0}
161 }%
162 }{\large $\Rightarrow$Jetzt wollen wir
163 einfach mal einen Text in einer
164 ziemlich gro\ss en ACHT schreiben,
165 aber richtig rum.}
166 \end{pspicture}
167 \end{LTXexample}
168
169 \medskip\noindent
170 The setting of the text along a path is very memory and calculation intensive on the
171 \PS side, so that with longer texts some seconds may pass until the desired
172 result appears even on faster computers. This is shown in the following example.
173 Note how the text is truncated as the path is too short to fit the entire text in.
174
175 \medskip\noindent
176 \begin{center}
177 \begin{pspicture}(-3,-3)(3,3)
178 \psset{linestyle=none}
179 \pstextpath[l](0,0){%
180 \parametricplot[plotstyle=curve,%
181 plotpoints=500]{0}{3000}{%
182 /r {t 1000 div} def t sin r mul t cos r mul }
183 }{
184 Du nimmst alles wahr, die Augen sind offen -
185 Doch Du verstehst nichts, du bist zu betroffen -
186 Die Angst bestimmt dein Handeln -
187 Es ist, als w\"urdest du dich verwandeln -
188 Ein anderer Mensch scheint es sehr -
189 Bist du nun und es geht gar nichts mehr -
190 Verzweifelt legst du dich nieder -
191 Doch der Frieden, er kommt nicht wieder -
192 Die Augen sind hellwach -
193 Es beginnt doch erst die Nacht -
194 Leicht d\"ammerst du in den Schlaf -
195 und kommst dir vor, wie in einem Grab -
196 Mit einem Mal bist du hellwach -
197 Es ist, als h\"attest du dauernd gedacht, -
198 Nun verstehst du alles, wie es war \ldots
199 }
200 \end{pspicture}
201 \end{center}
202
203 \begin{lstlisting}
204 %\usepackage{pst-plot}
205
206 \begin{pspicture}(-3,-3)(3,3)
207 \psset{linestyle=none}
208 \pstextpath[l](0,0){%
209 \parametricplot[plotstyle=curve,%
210 plotpoints=500]{0}{3000}{%
211 /r {t 1000 div} def t sin r mul t cos r mul }
212 }{
213 Du nimmst alles wahr, die Augen sind offen -
214 Doch Du verstehst nichts, du bist zu betroffen -
215 Die Angst bestimmt dein Handeln -
216 Es ist, als w\"urdest du dich verwandeln -
217 Ein anderer Mensch scheint es sehr -
218 Bist du nun und es geht gar nichts mehr -
219 Verzweifelt legst du dich nieder -
220 Doch der Frieden, er kommt nicht wieder -
221 Die Augen sind hellwach -
222 Es beginnt doch erst die Nacht -
223 Leicht d\"ammerst du in den Schlaf -
224 und kommst dir vor, wie in einem Grab -
225 Mit einem Mal bist du hellwach -
226 Es ist, als h\"attest du dauernd gedacht, -
227 Nun verstehst du alles, wie es war \ldots
228 }
229 \end{pspicture}
230 \end{lstlisting}
231
232
233
234
235 \section{Character manipulations}\label{sec:psttext:Zeichenmanipulationen}
236 % ---------------------------------------------------------------------------------------
237 With character manipulations the same issue with the \verb+DVI-PS+ driver applies,
238 namely that the results are only guaranteed for Rokicki's\index{Rokicki}
239 \Lprog{dvips} programme.\index{outline font}
240
241 % ---------------------------------------------------------------------------------------
242 \subsection{\nxLcs{pscharpath}}\label{sec:psttext:pscharpath}
243 % ---------------------------------------------------------------------------------------
244 Although the macro \Lcs{pscharpath} has a name similar to \Lcs{pstextpath}, it has a
245 completely different meaning.
246 %
247 \begin{BDef}
248 \Lcs{pscharpath}\OptArgs\Largb{Text}\\
249 \Lcs{pscharpath*}\OptArgs\Largb{Text}
250 \end{BDef}
251
252 \begin{description}
253 \item[Options] All \PST parameters, insofar as they make sense, may be
254 specified here.
255 \item[Text] The text to set, which may only consist of alphanumeric
256 characters, therefore no macros are possible within the text.
257 \end{description}
258
259 Normally, one will define ones own font size, which is best done with
260 \Lcs{DeclareFixedFont}, since this macro is very
261 fast because it simply sets the size without having to look up any font tables.
262
263 \medskip\noindent
264 \begin{LTXexample}[width=6.5cm,pos=l]
265 %\usepackage{pst-grad}
266 \DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{2cm}
267 \pscharpath{\RM TeXnik}\\
268 \pscharpath[linecolor=lightgray]{\RM TeXnik}\\
269 \psset{fillstyle=gradient,gradbegin=red,gradend=cyan}
270 \pscharpath[gradangle=90]{\RM TeXnik}\\
271 \pscharpath[linestyle=none,gradangle=-90]{\RM TeXnik}
272 \end{LTXexample}
273
274 \medskip\noindent
275 Normally the path, here the outer line of the characters, is deleted after the
276 macro \Lcs{pscharpath} has ended. With the asterisk version it is preserved
277 and can be used for other ``baubles''{}, for instance for \Lcs{pstextpath},
278 where the saved path can be used as input for the text to set.
279
280
281 \medskip\noindent
282 \DeclareFixedFont{\SF}{T1}{phv}{b}{n}{2.45cm}
283 \begin{center}
284 \pstextpath(0,-1ex){\pscharpath*[linestyle=none]{\SF Herbert Vo\ss}}{
285 \scriptsize Du nimmst alles wahr, die Augen sind offen -
286 Doch Du verstehst nichts, du bist zu betroffen -
287 Die Angst bestimmt dein Handeln -
288 Es ist, als w\"urdest du dich verwandeln -
289 Ein anderer Mensch scheint es sehr -
290 Bist du nun und es geht gar nichts mehr -
291 Verzweifelt legst du dich nieder -
292 Doch der Frieden, er kommt nicht wieder -
293 Die Augen sind hellwach -
294 Es beginnt doch erst die Nacht -
295 Leicht d\"mmerst du in den Schlaf -
296 und kommst dir vor, wie in einem Grab -
297 Mit einem Mal bist du hellwach -
298 Es ist, als h\"ttest du dauernd gedacht, -
299 Nun verstehst du alles, wie es war \ldots
300 }
301 \end{center}
302
303 \begin{lstlisting}
304 \DeclareFixedFont{\SF}{T1}{phv}{b}{n}{2.5cm}
305 \pstextpath(0,-1ex){%
306 \pscharpath*[linestyle=none]{\SF Herbert Vo\ss}}{
307 \scriptsize < ... Text ... >
308 }
309 \end{lstlisting}
310
311 % ---------------------------------------------------------------------------------------
312 \subsection{\nxLcs{pscharclip}}\label{sec:psttext:pscharclip}
313 % ---------------------------------------------------------------------------------------
314 \Lcs{pscharclip} is practically identical to
315 \Lcs{pscharpath} with the only difference being that it sets the clipping
316 path\index{clipping path} to the current path.
317 %
318 \begin{BDef}
319 \Lcs{pscharclip}\OptArgs\Largb{<text>} \% TeX example\\
320 \quad\ldots\\
321 \Lcs{endpscharclip}\\
322 \Lcs{pscharclip*}\OptArgs\Largb{<text>}\% TeX example\\
323 \quad\ldots\\
324 \Lcs{endpscharclip}\\
325 \LBEG{pscharclip}\OptArgs\Largb{<text>} \% LaTeX example\\
326 \quad\ldots\\
327 \LEND{pscharclip}\\
328 \LBEG{pscharclip*}\OptArgs\Largb{<text>}\% LaTeX example\\
329 \quad\ldots\\
330 \LEND{pscharclip}
331 \end{BDef}
332 %
333 Using this one can ``write''{} \emph{within} a font, whereas it is not really
334 easy to get the ``base''{} congruent. How to deal with this best shall is shown
335 in the following worked example.
336
337 The base is best formed as a \Lenv{minipage},
338 thus enabling it to be moved to arbitrary spots. To have clear coordinates on one hand
339 and only the interesting area shown on the other hand, one uses a
340 \Lenv{pspicture*} environment. Let us presume that we use a
341 font size of $3$cm and want to use the width of the whole page.
342 %
343 \begin{BDef}
344 \LBEG{pspicture*}\Largr{\Ldim{linewidth},3cm}\\
345 \quad\ldots\\
346 \LEND{pspicture}
347 \end{BDef}
348 %
349 The text can be set exactly into the centre with a \Lcs{rput} instruction.
350
351 \DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{3cm}
352 \begin{pspicture*}[showgrid=true](\linewidth,3cm)
353 \begin{pscharclip}[linewidth=0.1pt]{%
354 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
355 \end{pscharclip}
356 \end{pspicture*}
357
358 \begin{lstlisting}
359 \DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{3cm}
360 \begin{pspicture*}[showgrid=true](\linewidth,3cm)
361 \begin{pscharclip}[linewidth=0.1pt]{%
362 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
363 \end{pscharclip}
364 \end{pspicture*}
365 \end{lstlisting}
366
367 \medskip
368 The text ``lying below''{} the font is put into a \Lenv{minipage} of the
369 width \Ldim{linewidth}. Since this text underlies the
370 clipping path, it does not matter how long it really is, the essential thing is that the
371 the whole area is covered. This is especially important when the text is further
372 manipulated such as rotated. So one may view the following example with
373 \verb+\begin{minipage}{\linewidth}+.
374
375 \medskip
376 \DeclareFixedFont{\Rm}{T1}{ptm}{m}{n}{2mm}
377 \begin{pspicture*}[showgrid=true](\linewidth,3cm)
378 \rput{60}(0.5\linewidth,1.5){%
379 \begin{minipage}{0.6\linewidth}
380 \setstretch{0.5}
381 \color{red}
382 \multido{\i=1+1}{500}{\Rm PSTricks }
383 \end{minipage}%
384 }
385 \end{pspicture*}
386
387
388 \begin{lstlisting}
389 \DeclareFixedFont{\Rm}{T1}{ptm}{m}{n}{2mm}
390 \begin{pspicture*}[showgrid=true](\linewidth,3cm)
391 \rput{60}(0.5\linewidth,1.5){%
392 \begin{minipage}{0.6\linewidth}
393 \setstretch{0.5}
394 \color{red}
395 \multido{\i=1+1}{500}{\Rm PSTricks }
396 \end{minipage}%
397 }
398 \end{pspicture*}
399 \end{lstlisting}
400
401 \medskip
402 Both of these can be overlaid where, because of the clipping
403 path,\index{clipping path} only the inner of the large letters seems transparent.
404 In the second example the \Lenv{minipage} has been additionally rotated, the
405 line colour was ignored and the line spacing within the \Lenv{minipage} was
406 halved (package \LPack{setspace}).
407
408 \medskip
409 \begin{pspicture*}(\linewidth,3cm)
410 \begin{pscharclip}[linewidth=0.1pt]{%
411 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
412 \rput{60}(0.5\linewidth,1.5){%
413 \begin{minipage}{0.6\linewidth}
414 \setstretch{0.5}
415 \color{red}
416 \multido{\i=1+1}{500}{\Rm PSTricks }
417 \end{minipage}%
418 }
419 \end{pscharclip}
420 \end{pspicture*}
421
422 \begin{pspicture*}(\linewidth,3cm)
423 \begin{pscharclip}[linewidth=0.1pt,linestyle=none]{%
424 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
425 \rput{-60}(0.5\linewidth,1.5){%
426 \begin{minipage}{0.6\linewidth}
427 \setstretch{0.5}
428 \multido{\i=1+1}{500}{\Rm PSTricks }
429 \end{minipage}%
430 }
431 \end{pscharclip}
432 \end{pspicture*}
433
434
435 \begin{lstlisting}
436 \DeclareFixedFont{\RM}{T1}{ptm}{b}{n}{3cm}
437 \DeclareFixedFont{\Rm}{T1}{ptm}{m}{n}{2mm}
438 \begin{pspicture*}(\linewidth,3cm)
439 \begin{pscharclip}[linewidth=0.1pt]{%
440 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
441 \rput{60}(0.5\linewidth,1.5){%
442 \begin{minipage}{0.6\linewidth}
443 \setstretch{0.5}
444 \color{red}
445 \multido{\i=1+1}{500}{\Rm PSTricks }
446 \end{minipage}%
447 }
448 \end{pscharclip}
449 \end{pspicture*}
450
451 \begin{pspicture*}(\linewidth,3cm)
452 \begin{pscharclip}[linewidth=0.1pt,linestyle=none]{%
453 \rput(0.5\linewidth,1.5){\RM PSTricks}}%
454 \rput{-60}(0.5\linewidth,1.5){%
455 \begin{minipage}{0.6\linewidth}
456 \setstretch{0.5}
457 \multido{\i=1+1}{500}{\Rm PSTricks }
458 \end{minipage}%
459 }
460 \end{pscharclip}
461 \end{pspicture*}
462 \end{lstlisting}
463
464
465 \medskip
466 Generally it is not of interest what one bases \Lcs{pscharclip} on.
467 Using things sucha as a graphic can lead to some interesting possibilities.
468 It should be kept in mind that alternatively \Lcs{pscharpath} may be
469 used in conjunction with \Lcs{psboxfill}.
470
471
472 \section{Writing outline text on a circle}
473
474 \begin{BDef}
475 \Lcs{psCircleText}\OptArgs\OptArg{\Largr{x,y}}\Largb{Text}
476 \end{BDef}
477
478 Optional arguments are
479
480 \begin{description}
481 \item[\texttt{font}] Textfont, predefined as NimbusSanL-Regu. It must be a PostScript font.
482 \item[\texttt{fontsize}] Predefined to 24pt
483 \item[\texttt{fillcolor}] Predefined as red!40
484 \item[\texttt{radius}] The radius for the circled text
485 \end{description}
486
487
488 \begin{pspicture}[showgrid](10,10)
489 \psCircleText[fontsize=6.5mm,radius=4cm](5,5){All is Fun with the typesetting system TeX}%
490 \psCircleText[fillcolor=blue!40,fontsize=1cm,font=Helvetica](5,5){All is Fun within the World}%
491 \end{pspicture}
492
493
494 \begin{lstlisting}
495 \begin{pspicture}[showgrid](10,10)
496 \psCircleText[fontsize=6.5mm,radius=4cm](5,5){All is Fun with the typesetting system TeX}%
497 \psCircleText[fillcolor=blue!40,fontsize=1cm,font=Helvetica](5,5){All is Fun within the World}%
498 \end{pspicture}
499 \end{lstlisting}
500
501 The radius is preset to 2cm:
502
503 \begin{pspicture}(10,10)
504 \psCircleText[fontsize=6.5mm,radius=4cm](5,5){All is Fun with the typesetting system TeX}%
505 \psCircleText[fillcolor=blue!40,fontsize=1cm,font=Helvetica](5,5){All is Fun within the World}%
506 \pscircle[linecolor=red](5,5){4cm}\pscircle[linecolor=blue](5,5){2cm}
507 \end{pspicture}
508
509
510 \begin{lstlisting}
511 \begin{pspicture}(10,10)
512 \psCircleText[fontsize=6.5mm,radius=4cm](5,5){All is Fun with the typesetting system TeX}%
513 \psCircleText[fillcolor=blue!40,fontsize=1cm,font=Helvetica](5,5){All is Fun within the World}%
514 \pscircle[linecolor=red](5,5){4cm}\pscircle[linecolor=blue](5,5){2cm}
515 \end{pspicture}
516 \end{lstlisting}
517
518
519
520 \section{Warping a text}
521
522 \begin{BDef}
523 \Lcs{psWarp}\OptArgs\OptArg{\Largr{x,y}}\Largb{Text}
524 \end{BDef}
525
526 Optional arguments are
527
528 \begin{description}
529 \item[\texttt{font}] Textfont, predefined as NimbusSanL-Regu. It must be a PostScript font.
530 \item[\texttt{fontsize}] Predefined to 24pt
531 \item[\texttt{fillcolor}] Predefined as red!40
532 \item[\texttt{doublecolor}] The fillcolor for the doubleline, predefined as blue
533 \end{description}
534
535
536 \begin{pspicture}(10,5)
537 \psWarp[fillcolor=red!40,fontsize=0.5cm,font=Times-Roman]{All is Fun with the typesetting system LaTeX}%
538 \psWarp[fillcolor=green,fontsize=12pt](0,2){What a wonderfull day, it is raining and
539 I do not know what to do...}%
540 \end{pspicture}
541
542
543 \begin{lstlisting}
544 \begin{pspicture}(10,5)
545 \psWarp[fillcolor=red!40,fontsize=0.5cm,font=Times-Roman]{All is Fun with the typesetting system LaTeX}%
546 \psWarp[fillcolor=green,fontsize=12pt](0,2){What a wonderfull day, it is raining and
547 I do not know what to do...}%
548 \end{pspicture}
549 \end{lstlisting}
550
551
552 \nocite{*}
553 \bgroup
554 \RaggedRight
555 \printbibliography
556 \egroup
557
558 \printindex
559
560
561 \end{document}