diff options
Diffstat (limited to 'tmac')
-rw-r--r-- | tmac/dvi.tmac | 3 | ||||
-rw-r--r-- | tmac/html.tmac | 4 | ||||
-rw-r--r-- | tmac/ps.tmac | 3 | ||||
-rw-r--r-- | tmac/pspic.tmac | 66 | ||||
-rw-r--r-- | tmac/troffrc | 8 |
5 files changed, 67 insertions, 17 deletions
diff --git a/tmac/dvi.tmac b/tmac/dvi.tmac index ff5a2a27..a223b106 100644 --- a/tmac/dvi.tmac +++ b/tmac/dvi.tmac @@ -779,9 +779,6 @@ D\v'-.33m'\s0\v'.33m' . .cp \n(_C . -.if !\n(.C \ -. mso pspic.tmac -. .do ie '\[char97]'a' \ . do mso latin1.tmac .el \ diff --git a/tmac/html.tmac b/tmac/html.tmac index cd264465..8c5cacb4 100644 --- a/tmac/html.tmac +++ b/tmac/html.tmac @@ -533,10 +533,8 @@ . .cp \n(_C . -.if !\n(_C \{\ -. mso pspic.tmac +.if !\n(_C \ . mso www.tmac -.\} . .do ie '\[char97]'a' \ . do mso latin1.tmac diff --git a/tmac/ps.tmac b/tmac/ps.tmac index 39d43182..52f9975b 100644 --- a/tmac/ps.tmac +++ b/tmac/ps.tmac @@ -681,9 +681,6 @@ . .cp \n[_C] . -.if !\n(.C \ -. mso pspic.tmac -. .do ie '\[char97]'a' \ . do mso latin1.tmac .el \ diff --git a/tmac/pspic.tmac b/tmac/pspic.tmac index 9fe7e3eb..0fc4f12d 100644 --- a/tmac/pspic.tmac +++ b/tmac/pspic.tmac @@ -2,23 +2,35 @@ .\" .\" Define the PSPIC macro. .\" -.\" When used other than with -Tps, -Tdvi, or -Thtml it will draw a box +.\" When used other than with -Tps, -Tdvi, or -Thtml it draws a box .\" around where the picture would go. +.\" +.\" Usage: +.\" +.\" .PSPIC [-L|-R|-I <indent>] <file> [<width> [<height>]] +. +.do if d PSPIC .nx +. +.nr _C \n(.C +.cp 0 . .de PSPIC . nr ps-offset-mode 0 +. \" left-aligned? . ie '\\$1'-L' \{\ . nr ps-offset-mode 1 . shift . HTML-DO-IMAGE \\$1 l . \} . el \{\ +. \" right-aligned? . ie '\\$1'-R' \{\ . nr ps-offset-mode 2 . shift . HTML-DO-IMAGE \\$1 r . \} . el \{\ +. \" indented? . ie '\\$1'-I' \{\ . nr ps-offset-mode 3 . nr ps-offset (m;\\$2) @@ -32,6 +44,7 @@ . . br . +. \" get bounding box . psbb \\$1 . if (\\n[llx] : \\n[lly] : \\n[urx] : \\n[ury]) \{\ . nr ps-wid (\\n[urx] - \\n[llx]) @@ -40,22 +53,37 @@ . nr ps-wid (-\\n[ps-wid]) . if (\\n[ps-ht] < 0) \ . nr ps-ht (-\\n[ps-ht]) +. +. \" if we have a <width> parameter, use it as the final +. \" image width; otherwise we use the image's natural width +. \" or the current line length, whatever is smaller . ie (\\n[.$] >= 2) \ . nr ps-deswid (i;\\$2) . el \ . nr ps-deswid ((\\n[.l] - \\n[.i]) <? \\n[ps-wid]p) +. +. \" compute the final image height (with proper rounding), +. \" based on the image's aspect . nr ps-desht (\\n[ps-deswid] * 1000 + (\\n[ps-wid] / 2) \ / \\n[ps-wid] * \\n[ps-ht] \ + 500 / 1000) +. +. \" if we have a <height> parameter, use it as the final +. \" image height in case it is smaller than the height +. \" value we have just computed . if ((\\n[.$] >= 3) & (\\n[ps-desht] > (i;0\\$3))) \{\ . nr ps-desht (i;\\$3) +. \" recompute the final image width since we always +. \" keep the correct image aspect . nr ps-deswid (\\n[ps-desht] * 1000 + (\\n[ps-ht] / 2) \ / \\n[ps-ht] * \\n[ps-wid] \ + 500 / 1000) . \} . +. \" reserve vertical space for image . ne (\\n[ps-desht]u + 1v) . +. \" compute image offset w.r.t. the current left margin . if (\\n[ps-offset-mode] == 0) \ . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid] / 2) . if (\\n[ps-offset-mode] == 1) \ @@ -64,6 +92,7 @@ . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid]) . . ie '\*[.T]'dvi' \{\ +. \" prepare values for \special{psfile=...} as needed by dvips . ie (\\n[ps-wid]p == \\n[ps-deswid]) \{\ . ds ps-scale \" empty . ds ps-hoffset hoffset=-\\n[llx] @@ -83,18 +112,41 @@ \X'psfile=\\$1 \\*[ps-hoffset] \\*[ps-voffset] \\*[ps-scale]' . \} . el \{\ +. ie '\*[.T]'ps' \{\ +. \" prepare values for grops; the `ps-invis' and `ps-endinvis' escapes +. \" are for groff's -X switch to provide a PS preview with xditview: +. \" it uses -Tps for formatting but xditview can't handle EPS files, +. \" thus alternative code is enclosed between those two escapes +. ds ps-invis \X'ps: invis' +. ds ps-endinvis \X'ps: endinvis' +. ds ps-import \X'ps: import \E$1 \En[llx] \En[lly] \En[urx] \En[ury] \ + \En[ps-deswid] \E*[ps-desht]' +. \} +. el \{\ +. ds ps-invis +. ds ps-endinvis +. ds ps-import +. \} +. . ie (\\n[.$] >= 3) \ . ds ps-desht \\n[ps-desht] . el \ . ds ps-desht \" empty . \h'\\n[ps-offset]u'\ -\X'ps: invis'\ -\Z'\D'p 0 \\n[ps-desht]u \\n[ps-deswid]u 0 0 -\\n[ps-desht]u''\ -\X'ps: endinvis'\ +\\*[ps-invis]\ +\# horizontally, the rectangle is slightly smaller than the image +\# to compensate the line thickness (especially needed for TTY devices) +\Z'\D'p 0 \\n[ps-desht]u \ + (\\n[ps-deswid]u - \\n[.H]u) 0 \ + 0 -\\n[ps-desht]u''\ +\# for convenience we also display the image file name (centered vertically); +\Z'\v'((\\n[ps-desht]u / 2u) \ + + (\w'\\$1' * 0) \ + + ((\\n[rst]u + \\n[rsb]u) / 2u))'\h'1m'\\$1'\ +\\*[ps-endinvis]\ \v'\\n[ps-desht]u'\ -\X'ps: import \ - \\$1 \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[ps-deswid] \\*[ps-desht]' +\\*[ps-import] . \} . . br @@ -103,4 +155,6 @@ . HTML-IMAGE-END .. . +.cp \n[_C] +. .\" end of pspic.tmac diff --git a/tmac/troffrc b/tmac/troffrc index d73ace35..470f2627 100644 --- a/tmac/troffrc +++ b/tmac/troffrc @@ -27,7 +27,8 @@ .do rm troffrc!ps troffrc!Xps troffrc!dvi troffrc!X75 troffrc!X75-12 \ troffrc!X100 troffrc!X100-12 troffrc!lj4 troff!lbp troffrc!html . -.\" test whether we work under EBCDIC +.\" Test whether we work under EBCDIC and map the no-breakable space +.\" character accordingly. .do ie '\[char97]'a' \ . do tr \[char160]\~ .el \ @@ -40,7 +41,10 @@ troffrc!X100 troffrc!X100-12 troffrc!lj4 troff!lbp troffrc!html .do hpf hyphen.us .do hpfa hyphenex.us . -.\" Handle paper formats +.\" Handle paper formats. .do mso papersize.tmac . +.\" Handle PS images. +.do mso pspic.tmac +. .\" Don't let blank lines creep in here. |