Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/rotatetext.m4

raw
1 .PS
2 # rotatetext.m4
3 # This is a test of the pstricks \rput function to write a string around
4 # the periphery of a circle of radius r, accounting for inter-letter kerns
5 {\Huge
6 gen_init
7 twopi = twopi_
8 rtod = rtod_
9
10 define(`outputstring',`University of Waterloo')
11 r = 0.75
12 divert(-1)
13
14 sinclude(rotate.dim) # Letter and letter-pair width definitions
15 sinclude(tst.dim)
16 define(`arctot',0) # Total arc used by the string
17 sinclude(rotatetext.dim)
18
19 define(`cname',`ifelse(`$1',` ',,`$1')')
20
21 define(`cprint',`ifelse(len(`$3'),0,,
22 `define(`cc',`substr(`$3',0,1)')dnl
23 dt = atan2(boxdim(cname(cc),w)/2,`$2')
24 te = te + ifdef(`kern',`atan2(kern/2,`$2')',0) + dt
25
26 # The kernel of the print mechanism. All else is to calculate angles
27 sprintf("\rput[B]{%8.3f}(0,0){\boxdims{cname(cc)}{cc}}",(arctot/2-te)*rtod) \
28 with .bottom at `$1'+(rect_(`$2',arctot/2-te+twopi/4))
29
30 define(`kern',0) ifelse(len(`$3'),1,,cc,` ',,substr(`$3',1,1),` ',,
31 `define(`kern',`(boxdim(substr(`$3',0,2),w)-boxdim(
32 cname(substr(`$3',0,1)),w)-boxdim(cname(substr(`$3',1,1)),w))')dnl
33 \defboxdim{substr(`$3',0,2)}{substr(`$3',0,2)}')
34 if abs(kern/(1 pt__))>0.05 then {
35 print sprintf("k`'ern(substr(`$3',0,2))=%5.2gpt",kern/(1 pt__)) }
36 te = te + dt + atan2(kern/2,`$2')
37 cprint(`$1',`$2',substr(`$3',1))')')
38 divert
39
40 print sprintf("`arctot'=%g",arctot)
41
42 C: circle rad r
43 te = 0
44 cprint(C,r,outputstring)
45
46 # Write the total angle to rotatetext.dim
47 sh sprintf("echo \"`define'(`\`arctot'',%f)\" > rotatetext.dim",te)
48
49 }
50 .PE