Subject: v15i054: Sun previewer for TeX DVI files, Part01/04 Newsgroups: comp.sources.unix Sender: sources Approved: rsalz@uunet.UU.NET Submitted-by: Neil Hunt Posting-number: Volume 15, Issue 54 Archive-name: dvipage/part01 Dvipage is a program for previewing DVI files on Sun workstations. On a machine with a colour display, it renders each page of the document at high resolution and then filters and samples down the image to a lower spatial resolution, using grey scale resolution to maintain readability for the small character sizes. A magnifier is provided for close inspection of details of a page. On a monochrome display, these sampling features are not available, but rendering at low resolution is performed. This program is a significant development from the dvisun program which is in common use, offering improved user interfaces as well as advanced display features. The principle limitation of the current version is that it uses the PXL font description files, rather than any of the more compact forms which are available. Note that parts 2, 3 and 4 of this shar archive describe parts of the same file (dvipage.c) and must be unshared in order. # #--------------------------------CUT HERE------------------------------------- #! /bin/sh # # This is a shell archive. Save this into a file, edit it # and delete all lines above this comment. Then give this # file to sh by executing the command "sh file". The files # will be extracted into the current directory owned by # you with default permissions. # # The files contained herein are: # # -rw-r--r-- 1 hunt 1661 Apr 13 09:49 README # -rw-r--r-- 1 hunt 9619 Apr 12 13:42 dvipage.1 # -rw-r--r-- 1 hunt 1531 Apr 13 09:43 Makefile # -rw-r--r-- 1 hunt 7420 Apr 13 09:18 dvi.h # echo 'x - README' if test -f README; then echo 'shar: not overwriting README'; else sed 's/^X//' << '________This_Is_The_END________' > README XYou will need to have a set of 300dpi fonts (for colour machines) Xand 118 dpi fonts (for monochrome machines) in PXL format in some Xdirectory. (Talk to a metafont guru to find out how to make the fonts, Xif necessary.) X XEdit the Makefile to set FONT_AREA, PRINT_SPOOLER and PRINT_PAGE_SPOOLER Xcorrectly. X XFONT_AREA should point to the PXL file directory, for example X -D'FONTAREA="/usr/local/font/tex/pxl"' X XPRINT_SPOOLER and PRINT_PAGE_SPOOLER should define suitable commands Xfor printing the whole document or a single page; they are used as below: X sprintf(command, PRINT_SPOOLER, filename); X sprintf(command, PRINT_PAGE_SPOOLER, page, page, filename); XThere is currently no good, generic way to lpr a single page of a DVI Xfile; the `texpagefilter' program in the model in the Makefile is a Xconceptual program rather than something you will find today; Xif someone wants to write one... XA more practical version (for laserwriter users) is X -D'PRINT_PAGE_SPOOLER=dvips %s >/dev/null 2>/dev/null' X -D'PRINT_PAGE_SPOOLER=dvips -f %d -t %d %s >/dev/null 2>/dev/null' Xor for imagen users X -D'PRINT_PAGE_SPOOLER=dviimp %s >/dev/null 2>/dev/null' X -D'PRINT_PAGE_SPOOLER=dviimp -S %d -E %d %s >/dev/null 2>/dev/null' X XIf your site uses several kinds of printers, you could add code in main() Xto parse the PRINTER environment variable, and set appropriate commands for Xprinting documents and pages. See for example the few lines bracketed Xbetween `#ifdef SPAR_HACKS' in the function main() in dvipage.c X XRun `make dvipage' and install it in the proper place (perhaps /usr/local/bin). XInstall the manual page in the proper place (perhaps /usr/local/man/man1). X XNeil/. ________This_Is_The_END________ if test `wc -c < README` -ne 1661; then echo 'shar: README was damaged during transit (should have been 1661 bytes)' fi fi ; : end of overwriting check echo 'x - dvipage.1' if test -f dvipage.1; then echo 'shar: not overwriting dvipage.1'; else sed 's/^X//' << '________This_Is_The_END________' > dvipage.1 X.\" X.\" dvipage: DVI Previewer Program for Suns X.\" X.\" This program is based, in part, upon the program dvisun, X.\" distributed by the UnixTeX group, extensively modified by X.\" Neil Hunt at the Schlumberger Palo Alto Research Laboratories X.\" of Schlumberger Technologies, Inc. X.\" X.\" From the dvisun manual page entry: X.\" Mark Senn wrote the early versions of [dvisun] for the X.\" BBN BitGraph. Stephan Bechtolsheim, Bob Brown, Richard X.\" Furuta, James Schaad and Robert Wells improved it. Norm X.\" Hutchinson ported the program to the Sun. Further bug fixes X.\" by Rafael Bracho at Schlumberger. X.\" X.\" Copyright (c) 1988 Schlumberger Technologies, Inc 1988. X.\" Anyone can use this software in any manner they choose, X.\" including modification and redistribution, provided they make X.\" no charge for it, and these conditions remain unchanged. X.\" X.\" This program is distributed as is, with all faults (if any), and X.\" without any warranty. No author or distributor accepts responsibility X.\" to anyone for the consequences of using it, or for whether it serves any X.\" particular purpose at all, or any other reason. X.\" X.\" HISTORY X.\" X.\" 12 April 1988 - Neil Hunt X.\" Version 2.0 released for use. X.\" X.\" Earlier history unavailable. X.\" X.TH DVIPAGE 1 "4 February 1988" X.SH NAME Xdvipage \- display DVI files from TeX and LaTeX. X.SH SYNOPSIS X.B dvipage X.RB "[\|" \-H "\|]" X.RB "[\|" \-v X.IR mode "\|]" X.RB "[\|" \-m "\|]" X.RB "[\|" \-p "\|]" X.RB "[\|" \-q "\|]" X.RB "[\|" \-f "\|]" X.RB "[\|" \-r X.IR res "\|]" X.RB "[\|" \-s X.IR sample "\|]" X.RB "[\|" \-x X.IR x "\|]" X.RB "[\|" \-y X.IR y "\|]" X.RB "[\|" \-X X.IR X "\|]" X.RB "[\|" \-Y X.IR Y "\|]" X.RB "[\|" \-w X.IR w "\|]" X.RB "[\|" \-h X.IR h "\|]" X.RB "[\|" \-W... "\|]" X.RI "[\|" dvifile "[\|" .dvi "\|]\|]" X.SH DESCRIPTION X.IX dvipage "" "\fLdvipage\fR \(em display DVI files from TeX and LaTeX." X.I Dvipage Xdisplays DVI files produced by TeX or LaTeX on a SunView window. XA new window is created, and the first page of the document is displayed. XThe image of the page can be scrolled around in the window by Xgrabbing it with the middle mouse button, or by the keystrokes X.I "l r u d" (left, right, up, down). XThe X.I space Xkey or the keys X.I RET X.I n Xor X.I + Xadvance the display to the next page, Xwhile the X.I LF X.I p Xand X.I - Xkeys go back to the previous page. XThe right mouse button invokes a menu with options to Xmove forward or backward one page, to go to the first or last page Xin the document, Xto reopen the same, or a different, DVI file, Xto print either one page, or the whole document, Xor to exit. XVarious other key and menu options are described below. X.PP XOn a monochrome display, X.I dvipage Xuses a set of low resolution fonts, (typically 118 dots per inch), Xto display the text. XWhen a colour display is available, Xhigh resolution fonts are used, (typically 300 dpi), Xthe page is rendered onto an internal ``page'', Xand image processing functions are invoked to Xlow pass filter the data and sample it down to a lower resolution. XThe sampled data has substituted grey scale resolution for Xspatial resolution, and retains much better readability than Xsimple binary fonts at the same scale of display. XOn a colour display, four levels of sampling are possible, Xwith linear scales of 1, 2, 3 and 4. XThe default is a sampling factor of 4. X(Sampling factor 3 actually obtains three samples for each eight Xpixels horizontally and nine rows vertically, thus changing Xthe aspect ratio slightly.) X.PP XWhen a non unity sampling factor is used (the default on a colour display), Xa magnifier is available to inspect a local region of the high resolution Xunsampled data, by pressing the left mouse button. XThe magnifier my be dragged around the page by moving the mouse with the Xbutton down. X.SH OPTIONS X.PP X.TP X.B \-H XPrints a simple help message. X.TP X.BI \-v " mode" XSets a verboseness level for debugging (wizards only). X.TP X.B \-m XMakes X.B dvipage Xthink that it is running on a monochrome machine even if it finds Xa colour display. X.TP X.B \-p XNormally X.B dvipage Xseeks to the end of the DVI file and reads the cached font data located Xthere. XThe X.B \-p Xoption suppresses this behaviour, causing the font data to be obtained Xfrom the inline locations. XThis is much slower, especially when skipping pages, Xbut does allow the first few pages of a very long document to be Xpreviewed before TeX has finished writing the DVI file X(dangerous - X.B dvipage Xcrashes if it overtakes the end of the file !) X.TP X.B \-q XCertain errors detected by X.B dvipage Xare displayed in a pop up message window. XThe X.B \-q Xflag suppresses the generation of these windows. X.TP X.B \-f XTeX has a concept of a rendering window with margins one inch Xinside the edges of the paper; Xthe DVI coordinate system is relative to this frame. XAlthough it is possible (and even normal) to print outside Xthe boundaries of this frame, sometimes it is useful Xto see its location on the page. XThe X.B \-f Xoption causes the rendering frame to be shown on the page display. X.TP X.BI \-r " res" XCauses X.B dvipage Xto use fonts at a resolution of X.I res Xdots per inch. XIf this is not a suitable size, it will generate many Xerror messages as it fails to find font files at the specified Xresolution. XCommon sizes are 118 and 300 dots per inch. XIf this option is ommitted, X.B dvipage Xwill select the either the high resolution fonts (on a colour machine) Xor the low resolution fonts (on a monochrome machine). X.TP X.BI \-s " sample" XCauses X.B dvipage Xto use a sampling factor of X.I sample. XIf this is not one of (1, 2, 3, or 4) a blank page will result. XThis option is ignored if running on a monochrome machine. X.TP X.BI \-x " x " \-y " y" XThe position of the top left hand corner of the page Xfrom the top left hand corner of the display window, Xmeasured in inches, Xis set to be X.I "(x, y)" Xat the ``home'' position (the position at which each new page is displayed Xbefore moving it around with the mouse). X.TP X.BI \-X " X " \-Y " Y" XNormally the origin of the rendering window is set to be one inch Xfrom the corner of the page. XThis can be overriden by this option to match the actual behaviour of Xyour local printer. X.TP X.BI \-w " w " \-h " h" XSets the width and height of the paper on which the image is rendered; Xthe default is 8\(12 \mu 11 inches. Useful for viewing legal size or A4 size Xdocuments. X.SH COMMANDS X.PP XThe following keystrokes typed to the display window execute Xvarious commands. XSome of these can be performed from a menu option. XMany of the commands can be preceeded by a number, Xindicated by X.B # Xin the description below. X.TP X.B MS_MIDDLE XThe middle mouse button drags the page beneath the window to pan or scroll. X.B MS_LEFT XThe left mouse button invokes a magnifier on the page near the mouse, Xwhen running in sampled mode on a colour display. X.TP X.B space, RET, n, or + XAdvance to the next page in the document. X.TP X.B NL, p, or - XGo back to the previous page. X.TP X.BR _ " (underscore)" XGo to the first page in the document. X.TP X.B # g XGo to page number X.B #. X(If X.B # Xis ommitted, go to the last page in the document.) X.TP X.B # G XGo to sheet number X.B #. X(If X.B # Xis ommitted, go to the last page in the document.) X.TP X.B h XReturn the page to the home position. X.TP X.B l, r, u or d XMove the page left, right, up or down in the window by a small increment. X.TP X.B m XMark the current page position as the new home page position for subsequent Xnew pages and X.B h Xcommands. X.TP X.B S XPops up a window in which a sampling factor can be typed. XThis should be 1, 2, 3 or 4. XClose the window by mousing the X.B Abort Xbutton or the X.B OK Xbutton, Xor by typing X.B "^C" X(for abort) Xor X.B "ESC" X(for OK). X.TP X.B # s XSet a scaling factor of X.B #. X.TP X.B # R XReopen the current DVI file on page X.B #. X(If X.B # Xis ommitted, reopen on the current page.) X.TP X.B P XPrint the DVI file on the default printer. X(Invokes site dependent printer commands where possible, Xotherwise just calls X.B "lpr -d" X.TP X.B "^P" XAttempts to print the current page on the default printer. XThis requires site dependent printer commands to have Xbeen specified when X.B dvipage Xwas installed. X.TP X.B w XToggles the display of the rendering frame window. X.B # x XSets the width of the magnifier (in pixels). X.B # y XSets the height of the magnifier (in pixels). X.B # b XSets the width of the border drawn around the magnifier. XUse X.B 0 b Xto have no border. displayed. X.TP X.B # v XSets verbose mode X.B #. X.TP X.B q X.B dvipage Xquits. X.SH SEE ALSO Xdvips(1) X.SH BUGS X.PP XThe command to print the current page is rather Xcrude. It needs special magic at installation time Xto make it work. X.PP X.B Dvipage Xchecks the modification time of the dvi file before tackling each page, Xand refuses to proceed if you have reformatted the document, until you Xinstruct it to reopen the file. XHowever, if you reformat \fIwhile\fP it is in the process of reading a page, Xit will probably crash messily. X.PP X.B Dvipage Xstill uses the old style PXL files; it has not been updated to Xread to more compact formats which are in use at some sites. X.SH AUTHOR X.PP XThe original idea for this program came from X.B dvisun Xdeveloped by Mark Senn, Stephan Bechtolsheim, Bob Brown, XRichard Furuta, James Schaad, Robert Wells, and Norm Hutchinson, Xwith some bug fixes by Rafael Bracho at Schlumberger; Xand from the program X.B suntroff Xdeveloped by Malcolm Slaney at Schlumberger. X.PP X.B Dvipage Xwas put together by XNeil Hunt at Schlumberger Palo Alto Research, X.B hunt@spar.slb.com, Xusing code borrowed from X.B dvisun Xand greatly extended. XIn particular the filtering and sampling concept Xand the fast code to implement it, and the magnifier, Xcame from Neil Hunt. ________This_Is_The_END________ if test `wc -c < dvipage.1` -ne 9619; then echo 'shar: dvipage.1 was damaged during transit (should have been 9619 bytes)' fi fi ; : end of overwriting check echo 'x - Makefile' if test -f Makefile; then echo 'shar: not overwriting Makefile'; else sed 's/^X//' << '________This_Is_The_END________' > Makefile X# X# dvipage: DVI Previewer Program for Suns X# X# Neil Hunt (hunt@spar.slb.com) X# X# This program is based, in part, upon the program dvisun, X# distributed by the UnixTeX group, extensively modified by X# Neil Hunt at the Schlumberger Palo Alto Research Laboratories X# of Schlumberger Technologies, Inc. X# X# From the dvisun manual page entry: X# Mark Senn wrote the early versions of [dvisun] for the X# BBN BitGraph. Stephan Bechtolsheim, Bob Brown, Richard X# Furuta, James Schaad and Robert Wells improved it. Norm X# Hutchinson ported the program to the Sun. Further bug fixes X# by Rafael Bracho at Schlumberger. X# X# Copyright (c) 1988 Schlumberger Technologies, Inc 1988. X# Anyone can use this software in any manner they choose, X# including modification and redistribution, provided they make X# no charge for it, and these conditions remain unchanged. X# X# This program is distributed as is, with all faults (if any), and X# without any warranty. No author or distributor accepts responsibility X# to anyone for the consequences of using it, or for whether it serves any X# particular purpose at all, or any other reason. X# X# HISTORY X# X# 12 April 1988 - Neil Hunt X# Version 2.0 released for use. X# X# Earlier history unavailable. X# X X#C = -O -f68881 XC = -O XL = -lsuntool -lsunwindow -lpixrect X Xdvipage: dvipage.o X cc $C -o dvipage dvipage.o $L X Xdvipage.o: dvipage.c dvi.h X cc $C -c dvipage.c \ X '-DFONTAREA="/usr/local/font/tex/pxl"' \ X '-DPRINT_SPOOLER="lpr -d %s"' \ X '-DPRINT_PAGE_SPOOLER="texpagefilter -f %d -t %d %s | lpr -d"' ________This_Is_The_END________ if test `wc -c < Makefile` -ne 1531; then echo 'shar: Makefile was damaged during transit (should have been 1531 bytes)' fi fi ; : end of overwriting check echo 'x - dvi.h' if test -f dvi.h; then echo 'shar: not overwriting dvi.h'; else sed 's/^X//' << '________This_Is_The_END________' > dvi.h X/* X * dvipage: DVI Previewer Program for Suns X * X * Neil Hunt (hunt@spar.slb.com) X * X * This program is based, in part, upon the program dvisun, X * distributed by the UnixTeX group, extensively modified by X * Neil Hunt at the Schlumberger Palo Alto Research Laboratories X * of Schlumberger Technologies, Inc. X * X * From the dvisun manual page entry: X * Mark Senn wrote the early versions of [dvisun] for the X * BBN BitGraph. Stephan Bechtolsheim, Bob Brown, Richard X * Furuta, James Schaad and Robert Wells improved it. Norm X * Hutchinson ported the program to the Sun. Further bug fixes X * by Rafael Bracho at Schlumberger. X * X * Copyright (c) 1988 Schlumberger Technologies, Inc 1988. X * Anyone can use this software in any manner they choose, X * including modification and redistribution, provided they make X * no charge for it, and these conditions remain unchanged. X * X * This program is distributed as is, with all faults (if any), and X * without any warranty. No author or distributor accepts responsibility X * to anyone for the consequences of using it, or for whether it serves any X * particular purpose at all, or any other reason. X * X * HISTORY X * X * 12 April 1988 - Neil Hunt X * Version 2.0 released for use. X * X * Earlier history unavailable. X */ X X#define SETC_000 0 X#define SETC_001 1 X#define SETC_002 2 X#define SETC_003 3 X#define SETC_004 4 X#define SETC_005 5 X#define SETC_006 6 X#define SETC_007 7 X#define SETC_008 8 X#define SETC_009 9 X#define SETC_010 10 X#define SETC_011 11 X#define SETC_012 12 X#define SETC_013 13 X#define SETC_014 14 X#define SETC_015 15 X#define SETC_016 16 X#define SETC_017 17 X#define SETC_018 18 X#define SETC_019 19 X#define SETC_020 20 X#define SETC_021 21 X#define SETC_022 22 X#define SETC_023 23 X#define SETC_024 24 X#define SETC_025 25 X#define SETC_026 26 X#define SETC_027 27 X#define SETC_028 28 X#define SETC_029 29 X#define SETC_030 30 X#define SETC_031 31 X#define SETC_032 32 X#define SETC_033 33 X#define SETC_034 34 X#define SETC_035 35 X#define SETC_036 36 X#define SETC_037 37 X#define SETC_038 38 X#define SETC_039 39 X#define SETC_040 40 X#define SETC_041 41 X#define SETC_042 42 X#define SETC_043 43 X#define SETC_044 44 X#define SETC_045 45 X#define SETC_046 46 X#define SETC_047 47 X#define SETC_048 48 X#define SETC_049 49 X#define SETC_050 50 X#define SETC_051 51 X#define SETC_052 52 X#define SETC_053 53 X#define SETC_054 54 X#define SETC_055 55 X#define SETC_056 56 X#define SETC_057 57 X#define SETC_058 58 X#define SETC_059 59 X#define SETC_060 60 X#define SETC_061 61 X#define SETC_062 62 X#define SETC_063 63 X#define SETC_064 64 X#define SETC_065 65 X#define SETC_066 66 X#define SETC_067 67 X#define SETC_068 68 X#define SETC_069 69 X#define SETC_070 70 X#define SETC_071 71 X#define SETC_072 72 X#define SETC_073 73 X#define SETC_074 74 X#define SETC_075 75 X#define SETC_076 76 X#define SETC_077 77 X#define SETC_078 78 X#define SETC_079 79 X#define SETC_080 80 X#define SETC_081 81 X#define SETC_082 82 X#define SETC_083 83 X#define SETC_084 84 X#define SETC_085 85 X#define SETC_086 86 X#define SETC_087 87 X#define SETC_088 88 X#define SETC_089 89 X#define SETC_090 90 X#define SETC_091 91 X#define SETC_092 92 X#define SETC_093 93 X#define SETC_094 94 X#define SETC_095 95 X#define SETC_096 96 X#define SETC_097 97 X#define SETC_098 98 X#define SETC_099 99 X#define SETC_100 100 X#define SETC_101 101 X#define SETC_102 102 X#define SETC_103 103 X#define SETC_104 104 X#define SETC_105 105 X#define SETC_106 106 X#define SETC_107 107 X#define SETC_108 108 X#define SETC_109 109 X#define SETC_110 110 X#define SETC_111 111 X#define SETC_112 112 X#define SETC_113 113 X#define SETC_114 114 X#define SETC_115 115 X#define SETC_116 116 X#define SETC_117 117 X#define SETC_118 118 X#define SETC_119 119 X#define SETC_120 120 X#define SETC_121 121 X#define SETC_122 122 X#define SETC_123 123 X#define SETC_124 124 X#define SETC_125 125 X#define SETC_126 126 X#define SETC_127 127 X#define SET1 128 X#define SET2 129 X#define SET3 130 X#define SET4 131 X#define SET_RULE 132 X#define PUT1 133 X#define PUT2 134 X#define PUT3 135 X#define PUT4 136 X#define PUT_RULE 137 X#define NOP 138 X#define BOP 139 X#define EOP 140 X#define PUSH 141 X#define POP 142 X#define RIGHT1 143 X#define RIGHT2 144 X#define RIGHT3 145 X#define RIGHT4 146 X#define W0 147 X#define W1 148 X#define W2 149 X#define W3 150 X#define W4 151 X#define X0 152 X#define X1 153 X#define X2 154 X#define X3 155 X#define X4 156 X#define DOWN1 157 X#define DOWN2 158 X#define DOWN3 159 X#define DOWN4 160 X#define Y0 161 X#define Y1 162 X#define Y2 163 X#define Y3 164 X#define Y4 165 X#define Z0 166 X#define Z1 167 X#define Z2 168 X#define Z3 169 X#define Z4 170 X#define FONT_00 171 X#define FONT_01 172 X#define FONT_02 173 X#define FONT_03 174 X#define FONT_04 175 X#define FONT_05 176 X#define FONT_06 177 X#define FONT_07 178 X#define FONT_08 179 X#define FONT_09 180 X#define FONT_10 181 X#define FONT_11 182 X#define FONT_12 183 X#define FONT_13 184 X#define FONT_14 185 X#define FONT_15 186 X#define FONT_16 187 X#define FONT_17 188 X#define FONT_18 189 X#define FONT_19 190 X#define FONT_20 191 X#define FONT_21 192 X#define FONT_22 193 X#define FONT_23 194 X#define FONT_24 195 X#define FONT_25 196 X#define FONT_26 197 X#define FONT_27 198 X#define FONT_28 199 X#define FONT_29 200 X#define FONT_30 201 X#define FONT_31 202 X#define FONT_32 203 X#define FONT_33 204 X#define FONT_34 205 X#define FONT_35 206 X#define FONT_36 207 X#define FONT_37 208 X#define FONT_38 209 X#define FONT_39 210 X#define FONT_40 211 X#define FONT_41 212 X#define FONT_42 213 X#define FONT_43 214 X#define FONT_44 215 X#define FONT_45 216 X#define FONT_46 217 X#define FONT_47 218 X#define FONT_48 219 X#define FONT_49 220 X#define FONT_50 221 X#define FONT_51 222 X#define FONT_52 223 X#define FONT_53 224 X#define FONT_54 225 X#define FONT_55 226 X#define FONT_56 227 X#define FONT_57 228 X#define FONT_58 229 X#define FONT_59 230 X#define FONT_60 231 X#define FONT_61 232 X#define FONT_62 233 X#define FONT_63 234 X#define FNT1 235 X#define FNT2 236 X#define FNT3 237 X#define FNT4 238 X#define XXX1 239 X#define XXX2 240 X#define XXX3 241 X#define XXX4 242 X#define FNT_DEF1 243 X#define FNT_DEF2 244 X#define FNT_DEF3 245 X#define FNT_DEF4 246 X#define PRE 247 X#define POST 248 X#define POST_POST 249 X X#define FIRSTPXLCHAR 0 X#define LASTPXLCHAR 127 X#define NPXLCHARS 128 X#define PXLID 1001 ________This_Is_The_END________ if test `wc -c < dvi.h` -ne 7420; then echo 'shar: dvi.h was damaged during transit (should have been 7420 bytes)' fi fi ; : end of overwriting check exit 0