tmac.ps: support eps file names and link destinations with spaces
[neatroff_make.git] / tmac / tmac.eps
blob214d6bd6d556342e0092d08312f962f1df3c2ba4
1 .\" tmac.eps
2 .\"
3 .\" .EPS file.eps [L|R|C|indents] [width] [height]
4 .de EPS
5 .       ds eps.tmp /tmp/.eps.\n($$
6 .       \" obtaing the bounding box
7 .       ec @
8 .       sy cat "@$1" | sed -n '/%%BoundingBox: \([-0123456789]\{1,10\}\) \([-0123456789]\{1,10\}\) \([-0123456789]\{1,10\}\) \([-0123456789]\{1,10\}\)/{s//.nr llx 0+\1p,.nr lly 0+\2p,.nr urx 0+\3p,.nr ury 0+\4p/p; q; }' | tr ',' '\\n' >@*[eps.tmp]
9 .       ec
10 .       so \\*[eps.tmp]
11 .       sy rm \\*[eps.tmp]
12 .       \" image scaling
13 .       ie '\\$3'' .nr eps.scale 100
14 .       el .nr eps.scale ((\\$3)*100/(\\n[urx]-\\n[llx]))
15 .       if !'\\$4'' .if \\n[eps.scale]>(((\\$4)*100/(\\n[ury]-\\n[lly]))) \
16 .               nr eps.scale ((\\$4)*100/(\\n[ury]-\\n[lly]))
17 .       nr eps.w (\\n[urx]-\\n[llx])*\\n[eps.scale]/100
18 .       nr eps.h (\\n[ury]-\\n[lly])*\\n[eps.scale]/100
19 .       \" the placement
20 .       ie '\\$2'' .nr eps.in 0
21 .       el .nr eps.in (\\$2)
22 .       if '\\$2'L' .nr eps.in 0
23 .       if '\\$2'C' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])/2
24 .       if '\\$2'R' .nr eps.in (\\n(.l-\\n(.i-\\n[eps.w])
25 .       \" printing the image
26 .       br
27 .       ne \\n[eps.h]u
28 .       sp \\n[eps.h]u
29 \h'|\\n[eps.in]u'\\X'eps "\\$1" \\n[eps.w]'\h'\\n[eps.w]u'
30 .       br