1 .\" Define the PSPIC macro.
3 .\" When used with output devices other than ps, dvi, html, or xhtml,
4 .\" draw a box where the picture would go.
8 .\" .PSPIC [-L|-R|-C|-I <indentation>] <file> [<width> [<height>]]
12 .do nr *groff_pspic_tmac_C \n[.cp]
15 .\" This is called if the `psbb` request returned a bounding box of all
16 .\" zeroes. It already issues a diagnostic; one can append `ab` to this
17 .\" macro if that should be a fatal error, or redefine it for some other
28 . HTML-DO-IMAGE \\$1 l
35 . HTML-DO-IMAGE \\$1 r
41 . nr ps-offset (m;\\$2)
43 . HTML-DO-IMAGE \\$1 i
46 . \" centered is the default
49 . HTML-DO-IMAGE \\$1 c
58 . ie (\\n[llx] : \\n[lly] : \\n[urx] : \\n[ury]) \{\
59 . nr ps-wid (\\n[urx] - \\n[llx])
60 . nr ps-ht (\\n[ury] - \\n[lly])
61 . if (\\n[ps-wid] < 0) \
62 . nr ps-wid (-\\n[ps-wid])
63 . if (\\n[ps-ht] < 0) \
64 . nr ps-ht (-\\n[ps-ht])
66 . \" if we have a <width> parameter, use it as the final
67 . \" image width; otherwise we use the image's natural width
68 . \" or the current line length, whatever is smaller
70 . nr ps-deswid (i;\\$2)
72 . nr ps-deswid ((\\n[.l] - \\n[.i]) <? \\n[ps-wid]p)
74 . \" compute the final image height (with proper rounding),
75 . \" based on the image's aspect
76 . nr ps-desht (\\n[ps-deswid] * 1000 + (\\n[ps-wid] / 2) \
77 / \\n[ps-wid] * \\n[ps-ht] \
80 . \" if we have a <height> parameter, use it as the final
81 . \" image height in case it is smaller than the height
82 . \" value we have just computed
83 . if ((\\n[.$] >= 3) & (\\n[ps-desht] > (i;0\\$3))) \{\
84 . nr ps-desht (i;\\$3)
85 . \" recompute the final image width since we always
86 . \" keep the correct image aspect
87 . nr ps-deswid (\\n[ps-desht] * 1000 + (\\n[ps-ht] / 2) \
88 / \\n[ps-ht] * \\n[ps-wid] \
92 . \" reserve vertical space for image
93 . ne (\\n[ps-desht]u + 1v)
95 . \" compute image offset w.r.t. the current left margin
96 . if (\\n[ps-offset-mode] == 0) \
97 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid] / 2)
98 . if (\\n[ps-offset-mode] == 1) \
100 . if (\\n[ps-offset-mode] == 2) \
101 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid])
103 . ie '\*[.T]'dvi' \{\
104 . \" prepare values for \special{psfile=...} as needed by dvips
105 . ie (\\n[ps-wid]p == \\n[ps-deswid]) \{\
106 . ds ps-scale \" empty
107 . ds ps-hoffset hoffset=-\\n[llx]
108 . ds ps-voffset voffset=-\\n[lly]
111 . nr ps-scale (\\n[ps-deswid] * 100 / \\n[ps-wid]p)
112 . nr ps-hoffset (-\\n[llx] * \\n[ps-scale] / 100)
113 . nr ps-voffset (-\\n[lly] * \\n[ps-scale] / 100)
114 . ds ps-scale hscale=\\n[ps-scale] vscale=\\n[ps-scale]
115 . ds ps-hoffset hoffset=\\n[ps-hoffset]
116 . ds ps-voffset voffset=\\n[ps-voffset]
121 \X'psfile=\\$1 \\*[ps-hoffset] \\*[ps-voffset] \\*[ps-scale]'
125 . \" prepare values for grops; the 'ps-invis' and 'ps-endinvis'
126 . \" escapes are for groff's -X switch to provide a PS preview
127 . \" with xditview: it uses -Tps for formatting but xditview
128 . \" can't handle EPS files, thus alternative code is enclosed
129 . \" between those two escapes
130 . ds ps-invis \X'ps: invis'
131 . ds ps-endinvis \X'ps: endinvis'
132 . ds ps-import \X'ps: import \E$1 \En[llx] \En[lly] \En[urx] \En[ury] \
133 \En[ps-deswid] \E*[ps-desht]'
141 . ie (\\n[.$] >= 3) \
142 . ds ps-desht \\n[ps-desht]
144 . ds ps-desht \" empty
148 \# horizontally, the rectangle is slightly smaller than the image
149 \# to compensate the line thickness (especially needed for TTY devices)
150 \Z'\D'p 0 \\n[ps-desht]u \
151 (\\n[ps-deswid]u - \\n[.H]u) 0 \
153 \# for convenience we also display the image file name (centered
155 \Z'\v'((\\n[ps-desht]u / 2u) \
157 + ((\\n[rst]u + \\n[rsb]u) / 2u))'\h'1m'\\$1'\
167 . pspic*error-hook \\$@
171 .cp \n[*groff_pspic_tmac_C]
172 .do rr *groff_pspic_tmac_C
178 .\" vim: set expandtab filetype=groff tabstop=2 textwidth=72: