home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xdvi / patch14 < prev    next >
Encoding:
Text File  |  1992-06-28  |  56.7 KB  |  2,021 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!darwin.sura.net!mips!msi!dcmartin
  3. From: vojta%math.Berkeley.EDU@ucbvax.Berkeley.EDU (Paul Vojta)
  4. Subject: v17i106: xdvi, Patch14, Part01/01, Patch14, Part01/01
  5. Message-ID: <1992Jun29.160850.9316@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-17i106-xdvi@uunet.UU.NET>
  10. Date: Mon, 29 Jun 1992 16:08:50 GMT
  11. Approved: dcmartin@msi.com
  12. Lines: 2007
  13.  
  14. Submitted-by: vojta%math.Berkeley.EDU@ucbvax.Berkeley.EDU (Paul Vojta)
  15. Posting-number: Volume 17, Issue 106
  16. Archive-name: xdvi/patch14
  17. Patch-To: xdvi: Volume 17, Issues 23, 24, 25, 40, 41, 27, 53
  18.  
  19. This patch implements some greyscale anti-aliasing patches which have been
  20. requested by many people.  It also fixes the usual round of bugs.
  21.  
  22. Thanks go to Till Brychcy, Scott Allendorf, and many others for work
  23. on the greyscale patches.
  24.  
  25. --Paul Vojta, vojta@math.berkeley.edu
  26.  
  27. -- cut here --
  28. diff -cr xdvi_old/MAKE_VMS.COM xdvi_new/MAKE_VMS.COM
  29. *** xdvi_old/MAKE_VMS.COM    Sat Feb  8 14:07:52 1992
  30. --- xdvi_new/MAKE_VMS.COM    Sun Jun  7 11:30:44 1992
  31. ***************
  32. *** 1,16 ****
  33.   $ DEFINE X11 DECW$INCLUDE 
  34.   $ DEFINE SYS SYS$LIBRARY
  35. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) DVI_INIT
  36. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) DVI_DRAW
  37. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) FONTFMTS
  38. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) VF
  39. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) UTIL
  40. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL, -
  41. !      "DEFAULT_FONT_PATH=""TEX_FONTS""", -
  42.        "DEFAULT_VF_PATH=""TEX_FONTS""", -
  43. !      "DEFAULT_FONT_SIZES=""300/328.6/360/432/518.4/622/746.4""") FONT_OPEN
  44. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) TPIC
  45. ! $ CC /DEFINE = (BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL) XDVI
  46. ! $ LINK XDVI, DVI_INIT, DVI_DRAW, FONTFMTS, VF, UTIL, FONT_OPEN, TPIC, -
  47. !      VMS_C.OPT /OPTION
  48.   $ EXIT
  49. --- 1,16 ----
  50.   $ DEFINE X11 DECW$INCLUDE 
  51.   $ DEFINE SYS SYS$LIBRARY
  52. ! $ DEFS = "BMLONG, NOTOOL, USE_PK, USE_GF, USE_PXL, TEXXET, GREY"
  53. ! $ CC /DEFINE = ('DEFS') DVI_INIT.C
  54. ! $ CC /DEFINE = ('DEFS') DVI_DRAW.C
  55. ! $ CC /DEFINE = ('DEFS') FONTFMTS.C
  56. ! $ CC /DEFINE = ('DEFS') VF.C
  57. ! $ CC /DEFINE = ('DEFS') UTIL.C
  58. ! $ CC /DEFINE = ('DEFS', "DEFAULT_FONT_PATH=""TEX_FONTS""", -
  59.        "DEFAULT_VF_PATH=""TEX_FONTS""", -
  60. !      "DEFAULT_FONT_SIZES=""300/328.6/360/432/518.4/622/746.4""") FONT_OPEN.C
  61. ! $ CC /DEFINE = ('DEFS') TPIC.C
  62. ! $ CC /DEFINE = ('DEFS') XDVI.C
  63. ! $ LINK XDVI.OBJ, DVI_INIT.OBJ, DVI_DRAW.OBJ, FONTFMTS.OBJ, VF.OBJ, UTIL.OBJ, -
  64. !      FONT_OPEN.OBJ, TPIC.OBJ, VMS_C.OPT /OPTION
  65.   $ EXIT
  66. diff -cr xdvi_old/README xdvi_new/README
  67. *** xdvi_old/README    Fri Mar 27 21:03:14 1992
  68. --- xdvi_new/README    Mon Jun  1 16:25:55 1992
  69. ***************
  70. *** 79,84 ****
  71. --- 79,86 ----
  72.               definition of drawingWidgetClass.
  73.       TEXXET        (everything)  Enables op-codes 250 and 251 (used for
  74.               right-to-left languages).
  75. +     GREY        (everything)  Use greyscale anti-aliasing for
  76. +             displaying shrunken bitmaps.
  77.   
  78.   All flags should be set in the appropriate Makefile via the variable ``DEFS''.
  79.   
  80. ***************
  81. *** 244,248 ****
  82. --- 246,252 ----
  83.      30.    X11R5 support, and numerous bug fixes.
  84.   --  Patchlevel 13: --
  85.      31.  Added support for TeXXeT.
  86. + --  Patchlevel 14: --
  87. +    32.  Added support for greyscale anti-aliasing.
  88.   
  89.   Paul Vojta, vojta@math.berkeley.edu
  90. diff -cr xdvi_old/README.VMS xdvi_new/README.VMS
  91. *** xdvi_old/README.VMS    Mon Feb  4 13:08:20 1991
  92. --- xdvi_new/README.VMS    Sun Jun  7 22:47:16 1992
  93. ***************
  94. *** 8,15 ****
  95.   
  96.      XDVI [+[page]] [-s shrink] [-density density] [-p pixels] [-l] [-rv]
  97.           [-bw width] [-fg color] [-bg color] [-hl color] [-bd color] [-cr color]
  98. !         [-margins dimen] [-sidemargin dimen] [-topmargin dimen]
  99. !         [-offsets dimen] [-xoffset dimen] [-yoffset dimen] [-keep]
  100.           [-hushspecials] [-hushchars] [-hush] [-paper papertype] [-mgs[n] size]
  101.           [-altfont font] [-thorough] [-copy] [-geometry geometry]
  102.           [-icongeometry geometry] [-iconic] [-display display] dvi_file
  103. --- 8,15 ----
  104.   
  105.      XDVI [+[page]] [-s shrink] [-density density] [-p pixels] [-l] [-rv]
  106.           [-bw width] [-fg color] [-bg color] [-hl color] [-bd color] [-cr color]
  107. !         [-margins dimen] [-sidemargin dimen] [-topmargin dimen] [-version]
  108. !         [-offsets dimen] [-xoffset dimen] [-yoffset dimen] [-keep] [-nogrey]
  109.           [-hushspecials] [-hushchars] [-hush] [-paper papertype] [-mgs[n] size]
  110.           [-altfont font] [-thorough] [-copy] [-geometry geometry]
  111.           [-icongeometry geometry] [-iconic] [-display display] dvi_file
  112. ***************
  113. *** 107,112 ****
  114. --- 107,114 ----
  115.      -topmargin <dimen>    (.topMargin)  Specifies the top and bottom margins (see
  116.                            above).
  117.   
  118. +    -version              Print information on the version of XDVI.
  119.      -offsets <dimen>      (.Offset)  Specifies the size of both the horizontal
  120.                            and vertical offsets of the output on the page.  This
  121.                            should be a decimal number optionally followed by "cm",
  122. ***************
  123. *** 127,132 ****
  124. --- 129,140 ----
  125.                            should not move to the home position when moving to a
  126.                            new page.  See also the `k' keystroke.
  127.   
  128. +    -nogrey               (.grey)  Turns off the use greyscale anti-aliasing
  129. +                          when printing shrunken bitmaps.  In this case, the
  130. +                          logic of the corresponding resource is the reverse;
  131. +                          -nogrey corresponds to grey:off; +nogrey to grey:on.
  132. +                          See also the 'G' keystroke.
  133.      -hushspecials         (.hushSpecials)  Causes XDVI to suppress warnings about
  134.                            \special strings which it cannot process.
  135.   
  136. ***************
  137. *** 258,263 ****
  138. --- 266,275 ----
  139.           will keep the same position when moving between pages.  Also `0k' and
  140.           `1k' clear and set this flag, respectively.  See also the -keep option.
  141.   
  142. +    G   This key toggles the use of greyscale anti-aliasing for displaying
  143. +        shrunken bitmaps.  In addition, the key sequences `0G' and `1G' clear and
  144. +        set this flag, respectively.  See also the -nogrey option.
  145.   MOUSE ACTIONS
  146.   -------------
  147.   
  148. ***************
  149. *** 301,310 ****
  150.   
  151.      For compatibilty with some versions of TeX, you may also use the logical name
  152.      "TEXFONTS" in place of "XDVIFONTS", although in that case the string should
  153. !    not include any "%" specifiers.
  154.   
  155.      The logical name "XDVISIZES" must be set to indicate which sizes of fonts are
  156. !    available.  It should consists of a list of numbers separated by slashes.  If
  157.      the list begins with a slash, the system default sizes are used, as well.
  158.      Sizes are expressed in dots per inch; decimals may be used for "pxl" files:
  159.      for example, a 300 dots per inch file magnified by half a step comes out to
  160. --- 313,337 ----
  161.   
  162.      For compatibilty with some versions of TeX, you may also use the logical name
  163.      "TEXFONTS" in place of "XDVIFONTS", although in that case the string should
  164. !    not include any "%" specifiers.  The reason for recognizing "TEXFONTS" is
  165. !    that certain version of TeX also support the convention regarding an extra
  166. !    slash in the font path; therefore, users who create their own fonts can put
  167. !    both their .TFM and raster files in the same directory and do
  168.   
  169. +         $ DEFINE TEXFONTS "/MFDIR"
  170. +    or
  171. +         $ DEFINE TEXFONTS "MFDIR/"
  172. +    in order to get both TeX and XDVI to search their directory in addition to
  173. +    the system standard directories.  The "XDVIFONTS" logical name overrides the
  174. +    "TEXFONTS" logical name, so that on those sites where "TEXFONTS" must be set
  175. +    explicitly, and therefore this feature is not useful, the "XDVIFONTS" logical
  176. +    name be set to an empty string to cause XDVI to ignore "TEXFONTS".
  177.      The logical name "XDVISIZES" must be set to indicate which sizes of fonts are
  178. !    available.  It should consist of a list of numbers separated by slashes.  If
  179.      the list begins with a slash, the system default sizes are used, as well.
  180.      Sizes are expressed in dots per inch; decimals may be used for "pxl" files:
  181.      for example, a 300 dots per inch file magnified by half a step comes out to
  182. ***************
  183. *** 312,317 ****
  184. --- 339,350 ----
  185.      default set of sizes is 300/328.6/360/432/518.4/622/746.4.  XDVI will also
  186.      try the actual size of the font before trying any of the given sizes.
  187.   
  188. +    Virtual fonts are also supported, although XDVI does not have any built-in
  189. +    fonts to which they can refer.  The search path for .VF files can be
  190. +    specified with the "XDVIVFS" logical name in a similar manner to that for the
  191. +    "XDVIFONTS" logical name.  Virtual fonts are searched for immediately after
  192. +    looking for the font as a normal font in the exact size specified.
  193.   FILES
  194.   -----
  195.   
  196. ***************
  197. *** 362,371 ****
  198.            $ LIBRARY /INSERT HELPLIB.HLB XDVI.HLP
  199.   
  200.      4) Modify the command file you use to set up the TEX commands so that it
  201. !       defines the foreign symbol XDVI, and the logical names XDVIFONTS and
  202. !       XDVISIZES.  For more information on the expected contents of the logical
  203. !       names, see the LOGICAL NAMES section of this document.  The following
  204. !       lines are what I use locally:
  205.   
  206.         $ PROC      = F$ENVIRONMENT ("PROCEDURE")
  207.         $ TEXDIR    = F$PARSE (PROC, , , "DEVICE", "NO_CONCEAL") + -
  208. --- 395,404 ----
  209.            $ LIBRARY /INSERT HELPLIB.HLB XDVI.HLP
  210.   
  211.      4) Modify the command file you use to set up the TEX commands so that it
  212. !       defines the foreign symbol XDVI, and the logical names "XDVIFONTS",
  213. !       "XDVIVFS", and "XDVISIZES".  For more information on the expected contents
  214. !       of the logical names, see the LOGICAL NAMES section of this document.  The
  215. !       following lines are what I use locally:
  216.   
  217.         $ PROC      = F$ENVIRONMENT ("PROCEDURE")
  218.         $ TEXDIR    = F$PARSE (PROC, , , "DEVICE", "NO_CONCEAL") + -
  219. ***************
  220. *** 390,395 ****
  221. --- 423,429 ----
  222.         $!
  223.         $ XDVI :== "$TEX_EXE:XDVI"
  224.         $ DEFINE XDVIFONTS "TEX_PIXELS:[DPI%d]%f.%p"
  225. +       $ DEFINE XDVIVFS   XDVIFONTS
  226.         $ DEFINE XDVISIZES -
  227.                 "300/328.6/360/432/518.4/600/622/746.4/895.8/1075/1200/1290/1548"
  228.         $ EXIT
  229. ***************
  230. *** 407,413 ****
  231.                       Iowa City, IA 52242
  232.   
  233.                       Phone: (319) 335-1960
  234. !                     Email: allendorf@iowasp.physics.uiowa.edu
  235.   
  236.   AUTHORS
  237.   -------
  238. --- 441,447 ----
  239.                       Iowa City, IA 52242
  240.   
  241.                       Phone: (319) 335-1960
  242. !                     Email: scott-allendorf@uiowa.edu
  243.   
  244.   AUTHORS
  245.   -------
  246. diff -cr xdvi_old/XDVI.RNH xdvi_new/XDVI.RNH
  247. *** xdvi_old/XDVI.RNH    Mon Feb  4 13:09:35 1991
  248. --- xdvi_new/XDVI.RNH    Sun Jun  7 22:47:17 1992
  249. ***************
  250. *** 9,14 ****
  251. --- 9,15 ----
  252.   .! Merged with patchlevel 8.001 help file for VMS by Scott Allendorf.
  253.   .! Added new switches for patchlevel 10.  Scott Allendorf.
  254.   .! Added new switches for patchlevel 11.  Scott Allendorf.
  255. + .! Added new switches for patchlevel 14.  Scott Allendorf.
  256.   .!
  257.   .NO PAGING
  258.   .NO FLAGS ALL
  259. ***************
  260. *** 227,232 ****
  261. --- 228,244 ----
  262.   .SKIP
  263.   The resource name is ".listFonts".
  264.   .INDENT -1
  265. + 3 -nogrey
  266. + .BREAK
  267. + -nogrey
  268. + .SKIP
  269. + Turns off the use of greyscale anti-aliasing when printing shrunken bitmaps.
  270. + (In this case, the logic of the corresponding resource is the reverse;
  271. + -nogrey corresponds to grey:off; +nogrey to grey:on).
  272. + See also 'G' under the Keystrokes help entry.
  273. + .SKIP
  274. + The resource name is ".grey".
  275. + .INDENT -1
  276.   3 -offsets
  277.   .BREAK
  278.   -offsets <dimen>
  279. ***************
  280. *** 342,347 ****
  281. --- 354,365 ----
  282.   .SKIP
  283.   The resource name is ".topMargin".
  284.   .INDENT -1
  285. + 3 -version
  286. + .BREAK
  287. + -version
  288. + .SKIP
  289. + Print information on the version of XDVI.
  290. + .INDENT -1
  291.   3 -xoffset
  292.   .BREAK
  293.   -xoffset <dimen>
  294. ***************
  295. *** 457,462 ****
  296. --- 475,486 ----
  297.   well.  The `k' keystroke toggles a `keep-position' flag which, when
  298.   set, will keep the same position when moving between pages.  Also `0k'
  299.   and `1k' clear and set this flag, respectively.  See also the -keep option.
  300. + .INDENT -1
  301. + 3 G
  302. + .BREAK
  303. + The key toggles the use of greyscale anti-aliasing for displaying shrunken 
  304. + bitmaps.  In addition, the key sequences `0G' and `1G' clear and set this flag,
  305. + respectively.  See also the -nogrey option.
  306.   
  307.   .INDENT -1
  308.   2 Mouse_Actions
  309. ***************
  310. *** 528,533 ****
  311. --- 552,566 ----
  312.   inches, which should be encoded as 328.6.  The current default set of
  313.   sizes is 300/328.6/360/432/518.4/622/746.4.  XDVI will also try the actual
  314.   size of the font before trying any of the given sizes.
  315. + .INDENT -1
  316. + 3 XDVIVFS
  317. + .BREAK
  318. + Virtual fonts are supported, although XDVI does not have any built-in fonts to
  319. + which they can refer.  The search path for .VF files can be specified with the
  320. + "XDVIVFS" logical name in a similar manner to that for the "XDVIFONTS" logical
  321. + name.  Virtual fonts are searched for immediately after looking for the font
  322. + as a normal font in the exact size specified.
  323.   
  324.   .INDENT -1
  325.   2 Resource_Names
  326. diff -cr xdvi_old/dvi_draw.c xdvi_new/dvi_draw.c
  327. *** xdvi_old/dvi_draw.c    Sat Mar 28 13:00:26 1992
  328. --- xdvi_new/dvi_draw.c    Mon Jun  1 18:08:40 1992
  329. ***************
  330. *** 14,19 ****
  331. --- 14,20 ----
  332.    * 4/1989    Modified for System V by Donald Richardson, Clarkson Univ.
  333.    * 3/1990    Added VMS support    --Scott Allendorf, U of Iowa
  334.    * 7/1990    Added reflection mode    --Michael Pak, Hebrew U of Jerusalem
  335. +  * 1/1992    Added greyscale code    --Till Brychcy, Techn. Univ. Muenchen
  336.    *
  337.    *    Compilation options:
  338.    *    SYSV    compile for System V
  339. ***************
  340. *** 27,32 ****
  341. --- 28,34 ----
  342.    *    ALTFONT    default for -altfont option
  343.    *    A4    use European size paper
  344.    *    TEXXET    support reflection dvi codes (right-to-left typesetting)
  345. +  *    GREY    use grey levels to shrink fonts
  346.    */
  347.   
  348.   #include <ctype.h>
  349. ***************
  350. *** 37,42 ****
  351. --- 39,54 ----
  352.   #include <stdlib.h>
  353.   #endif
  354.   
  355. + #if    NeedVarargsPrototypes        /* this is for tell_oops */
  356. + #include <stdarg.h>
  357. + #else
  358. + #include <varargs.h>
  359. + #endif
  360. + #ifdef    DOPRNT    /* define this if vfprintf gives you trouble */
  361. + #define    vfprintf(stream, message, args)    _doprnt(message, args, stream)
  362. + #endif
  363.   static    struct frame    frame0;        /* dummy head of list */
  364.   #ifdef    TEXXET
  365.   static    struct frame    *scan_frame;    /* head frame for scanning */
  366. ***************
  367. *** 96,107 ****
  368.   
  369.   extern    char    *xmalloc();
  370.   
  371. ! #ifndef VMS
  372. ! extern    off_t    lseek();
  373. ! #else
  374. ! extern    int    lseek();
  375.   #endif
  376. ! extern    long    tell();
  377.   
  378.   #ifndef    SEEK_SET    /* if <unistd.h> is not provided (or for <X11R5) */
  379.   #define    SEEK_SET    0
  380. --- 108,117 ----
  381.   
  382.   extern    char    *xmalloc();
  383.   
  384. ! #ifdef    VMS
  385. ! #define    off_t    int
  386.   #endif
  387. ! extern    off_t    lseek();
  388.   
  389.   #ifndef    SEEK_SET    /* if <unistd.h> is not provided (or for <X11R5) */
  390.   #define    SEEK_SET    0
  391. ***************
  392. *** 111,117 ****
  393. --- 121,223 ----
  394.   
  395.   static    void    draw_part();
  396.   
  397. + /*
  398. +  *    Byte reading routines for dvi file.
  399. +  */
  400. + #define    xtell(pos)    (lseek(fileno(dvi_file), 0L, SEEK_CUR) - \
  401. +                 (currinf.end - (pos)))
  402. + static    ubyte
  403. + xxone()
  404. + {
  405. +     if (currinf.virtual) {
  406. +         ++currinf.pos;
  407. +         return EOP;
  408. +     }
  409. +     currinf.end = dvi_buffer +
  410. +         read(fileno(dvi_file), (char *) (currinf.pos = dvi_buffer),
  411. +         DVI_BUFFER_LEN);
  412. +     return currinf.end > dvi_buffer ? *(currinf.pos)++ : EOF;
  413. + }
  414. + #define    xone()  (currinf.pos < currinf.end ? *(currinf.pos)++ : xxone())
  415. + static    unsigned long
  416. + xnum(size)
  417. +     register ubyte size;
  418. + {
  419. +     register long x = 0;
  420. +     while (size--) x = (x << 8) | xone();
  421. +     return x;
  422. + }
  423. + static    long
  424. + xsnum(size)
  425. +     register ubyte size;
  426. + {
  427. +     register long x;
  428. + #ifdef    __STDC__
  429. +     x = (signed char) xone();
  430. + #else
  431. +     x = xone();
  432. +     if (x & 0x80) x -= 0x100;
  433. + #endif
  434. +     while (--size) x = (x << 8) | xone();
  435. +     return x;
  436. + }
  437. + #define    xsfour()    xsnum(4)
  438.   static    void
  439. + xskip(offset)
  440. +     long    offset;
  441. + {
  442. +     currinf.pos += offset;
  443. +     if (!currinf.virtual && currinf.pos > currinf.end)
  444. +         (void) lseek(fileno(dvi_file), (long) (currinf.pos - currinf.end),
  445. +         SEEK_CUR);
  446. + }
  447. + #if    NeedVarargsPrototypes
  448. + static    volatile void
  449. + tell_oops(_Xconst char *message, ...)
  450. + #else
  451. + /* VARARGS */
  452. + static    volatile void
  453. + tell_oops(va_alist)
  454. +     va_dcl
  455. + #endif
  456. + {
  457. + #if    !NeedVarargsPrototypes
  458. +     _Xconst char *message;
  459. + #endif
  460. +     va_list    args;
  461. +     Fprintf(stderr, "%s: ", prog);
  462. + #if    NeedVarargsPrototypes
  463. +     va_start(args, message);
  464. + #else
  465. +     va_start(args);
  466. +     message = va_arg(args, _Xconst char *);
  467. + #endif
  468. +     (void) vfprintf(stderr, message, args);
  469. +     va_end(args);
  470. +     if (currinf.virtual)
  471. +         Fprintf(stderr, " in virtual font %s\n", currinf.virtual->fontname);
  472. +     else
  473. +         Fprintf(stderr, ", offset %d\n", xtell(currinf.pos - 1));
  474. +     exit(1);
  475. + }
  476. + /*
  477. +  *    Code for debugging options.
  478. +  */
  479. + static    void
  480.   print_bitmap(bitmap)
  481.       register struct bitmap *bitmap;
  482.   {
  483. ***************
  484. *** 183,253 ****
  485.       else s = dvi_table2[ch - (FNTNUM0 + 64)];
  486.       if (s) puts(s);
  487.       else
  488. !         if (currinf.virtual)
  489. !         oops("Unknown op-code %d in virtual font", ch);
  490. !         else
  491. !         oops("Unknown op-code %d, offset %d", ch,
  492. !             tell(fileno(dvi_file)) - (currinf.end - currinf.pos + 1));
  493.   }
  494.   
  495. - /*
  496. -  *    Byte reading routines for dvi file.
  497. -  */
  498.   
  499. - static    ubyte
  500. - xxone()
  501. - {
  502. -     if (currinf.virtual) {
  503. -         ++currinf.pos;
  504. -         return EOP;
  505. -     }
  506. -     currinf.end = dvi_buffer +
  507. -         read(fileno(dvi_file), (char *) (currinf.pos = dvi_buffer),
  508. -         DVI_BUFFER_LEN);
  509. -     return currinf.end > dvi_buffer ? *(currinf.pos)++ : EOF;
  510. - }
  511. - #define    xone()  (currinf.pos < currinf.end ? *(currinf.pos)++ : xxone())
  512. - static    unsigned long
  513. - xnum(size)
  514. -     register ubyte size;
  515. - {
  516. -     register long x = 0;
  517. -     while (size--) x = (x << 8) | xone();
  518. -     return x;
  519. - }
  520. - static    long
  521. - xsnum(size)
  522. -     register ubyte size;
  523. - {
  524. -     register long x;
  525. - #ifdef    __STDC__
  526. -     x = (signed char) xone();
  527. - #else
  528. -     x = xone();
  529. -     if (x & 0x80) x -= 0x100;
  530. - #endif
  531. -     while (--size) x = (x << 8) | xone();
  532. -     return x;
  533. - }
  534. - #define    xsfour()    xsnum(4)
  535. - static    void
  536. - xskip(offset)
  537. -     long    offset;
  538. - {
  539. -     currinf.pos += offset;
  540. -     if (!currinf.virtual && currinf.pos > currinf.end)
  541. -         (void) lseek(fileno(dvi_file), (long) (currinf.pos - currinf.end),
  542. -         SEEK_CUR);
  543. - }
  544.   /*
  545.    *    Count the number of set bits in a given region of the bitmap
  546.    */
  547. --- 289,298 ----
  548.       else s = dvi_table2[ch - (FNTNUM0 + 64)];
  549.       if (s) puts(s);
  550.       else
  551. !         tell_oops("unknown op-code %d", ch);
  552.   }
  553.   
  554.   
  555.   /*
  556.    *    Count the number of set bits in a given region of the bitmap
  557.    */
  558. ***************
  559. *** 303,309 ****
  560. --- 348,468 ----
  561.       return n;
  562.   }
  563.   
  564. + #ifdef    GREY
  565.   static    void
  566. + shrink_glyph_grey(g)
  567. +     register struct glyph *g;
  568. + {
  569. +     int    shrunk_bytes_wide, shrunk_height;
  570. +     int    rows_left, rows, init_cols, cols_left;
  571. +     register int    cols;
  572. +     int    x, y;
  573. +     long    thesample;
  574. +     BMUNIT    *old_ptr, *new_ptr;
  575. +     register BMUNIT    m, *cp;
  576. +     int    min_sample = shrink_factor * shrink_factor * density / 100;
  577. +     /* These machinations ensure that the character is shrunk according to
  578. +        its hot point, rather than its upper left-hand corner. */
  579. +     g->x2 = g->x / shrink_factor;
  580. +     init_cols = g->x - g->x2 * shrink_factor;
  581. +     if (init_cols <= 0) init_cols += shrink_factor;
  582. +     else ++g->x2;
  583. +     g->bitmap2.w = g->x2 + ROUNDUP(g->bitmap.w - g->x, shrink_factor);
  584. +     /* include row zero with the positively numbered rows */
  585. +     cols = g->y + 1; /* spare register variable */
  586. +     g->y2 = cols / shrink_factor;
  587. +     rows = cols - g->y2 * shrink_factor;
  588. +     if (rows <= 0) {
  589. +         rows += shrink_factor;
  590. +         --g->y2;
  591. +     }
  592. +     g->bitmap2.h = shrunk_height = g->y2 +
  593. +         ROUNDUP(g->bitmap.h - cols, shrink_factor) + 1;
  594. +     if (g->bitmap2.bits) free(g->bitmap2.bits);
  595. +     alloc_bitmap(&g->bitmap2);
  596. +     if (g->pixmap2)
  597. +         XDestroyImage(g->image2);
  598. +     g->pixmap2 = xmalloc((unsigned) (g->bitmap2.bytes_wide * g->bitmap2.h *
  599. +                    DefaultDepthOfScreen(SCRN)), "character pixmap");
  600. +     g->image2 = XCreateImage(DISP,DefaultVisualOfScreen(SCRN),
  601. +                  DefaultDepthOfScreen(SCRN),
  602. +                  XYPixmap, 0, g->pixmap2,
  603. +                  g->bitmap2.w, g->bitmap2.h,
  604. +                  BITS_PER_BMUNIT, 0);
  605. +     old_ptr = (BMUNIT *) g->bitmap.bits;
  606. +     new_ptr = (BMUNIT *) g->bitmap2.bits;
  607. +     shrunk_bytes_wide = g->bitmap2.bytes_wide;
  608. +     rows_left = g->bitmap.h;
  609. +     bzero((char *) new_ptr, shrunk_bytes_wide * shrunk_height);
  610. +     y = 0;
  611. +     while (rows_left) {
  612. +         x = 0;
  613. +         if (rows > rows_left) rows = rows_left;
  614. +         cols_left = g->bitmap.w;
  615. + #ifndef    MSBITFIRST
  616. +         m = (1 << 0);
  617. + #else
  618. +         m = (1 << (BITS_PER_BMUNIT-1));
  619. + #endif
  620. +         cp = new_ptr;
  621. +         cols = init_cols;
  622. +         while (cols_left) {
  623. +         if (cols > cols_left) cols = cols_left;
  624. +         if ((thesample = sample(old_ptr, g->bitmap.bytes_wide,
  625. +             g->bitmap.w - cols_left, cols, rows)) >= min_sample)
  626. +             *cp |= m;
  627. + #ifndef    MSBITFIRST
  628. +         if (m == (BMUNIT)(1 << (BITS_PER_BMUNIT-1))) {
  629. +             m = (1 << 0);
  630. +             ++cp;
  631. +         }
  632. +         else m <<= 1;
  633. + #else
  634. +         if (m == (1 << 0)) {
  635. +             m = (1 << (BITS_PER_BMUNIT-1));
  636. +             ++cp;
  637. +         }
  638. +         else m >>= 1;
  639. + #endif
  640. +         cols_left -= cols;
  641. +         cols = shrink_factor;
  642. +         if (shrink_factor == 2)
  643. +             XPutPixel(g->image2, x, y, pixel2[thesample]);
  644. +         else if (shrink_factor == 3)
  645. +             XPutPixel(g->image2, x, y, pixel3[thesample]);
  646. +         else if (shrink_factor == 4)
  647. +             XPutPixel(g->image2, x, y, pixel4[thesample]);
  648. +         else
  649. +             XPutPixel(g->image2, x, y,
  650. +             pixel4[thesample * 16 / shrink_factor / shrink_factor]);
  651. +         x++;
  652. +         }
  653. +         *((char **) &new_ptr) += shrunk_bytes_wide;
  654. +         *((char **) &old_ptr) += rows * g->bitmap.bytes_wide;
  655. +         rows_left -= rows;
  656. +         rows = shrink_factor;
  657. +         y++;
  658. +     }
  659. +     while (y < g->bitmap2.h) {
  660. +         for (x = 0; x < g->bitmap2.w; x++)
  661. +         XPutPixel(g->image2, x, y, pixel2[0]);
  662. +         y++;
  663. +     }
  664. +     g->y2 = g->y / shrink_factor;
  665. +     if (debug & DBG_BITMAP)
  666. +         print_bitmap(&g->bitmap2);
  667. + }
  668. + #endif    /* GREY */
  669. + static    void
  670.   shrink_glyph(g)
  671.       register struct glyph *g;
  672.   {
  673. ***************
  674. *** 397,403 ****
  675.               load_font(currinf.fontp);
  676.           break;
  677.           }
  678. !     if (currinf.fontp == NULL) oops("Non-existent font #%d", n);
  679.       maxchar = currinf.fontp->maxchar;
  680.       currinf.set_char_p = currinf.fontp->set_char_p;
  681.   }
  682. --- 556,562 ----
  683.               load_font(currinf.fontp);
  684.           break;
  685.           }
  686. !     if (currinf.fontp == NULL) tell_oops("non-existent font #%d", n);
  687.       maxchar = currinf.fontp->maxchar;
  688.       currinf.set_char_p = currinf.fontp->set_char_p;
  689.   }
  690. ***************
  691. *** 470,479 ****
  692. --- 629,652 ----
  693.           if (shrink_factor == 1)
  694.           put_bitmap(&g->bitmap, PXL_H - g->x, PXL_V - g->y);
  695.           else {
  696. + #ifdef    GREY
  697. +         if (use_grey) {
  698. +             if (g->pixmap2 == NULL) {
  699. +             shrink_glyph_grey(g);
  700. +             }
  701. +             put_image(g->image2, PXL_H - g->x2, PXL_V - g->y2);
  702. +         } else {
  703. +             if (g->bitmap2.bits == NULL) {
  704. +             shrink_glyph(g);
  705. +             }
  706. +             put_bitmap(&g->bitmap2, PXL_H - g->x2, PXL_V - g->y2);
  707. +         }
  708. + #else
  709.           if (g->bitmap2.bits == NULL) {
  710.               shrink_glyph(g);
  711.           }
  712.           put_bitmap(&g->bitmap2, PXL_H - g->x2, PXL_V - g->y2);
  713. + #endif
  714.           }
  715.   #ifndef    TEXXET
  716.       return g->dvi_adv;
  717. ***************
  718. *** 524,533 ****
  719.           currinf.tn_head = currinf.fontp->vf_chain;
  720.           currinf.pos = m->pos;
  721.           currinf.end = m->end;
  722. !         currinf.virtual = True;
  723.           draw_part(current_frame, currinf.fontp->dimconv);
  724.           if (currinf.pos != currinf.end + 1)
  725. !         oops("Virtual character macro does not end correctly.");
  726.           currinf = oldinfo;
  727.           maxchar = oldmaxchar;
  728.   #ifndef    TEXXET
  729. --- 697,706 ----
  730.           currinf.tn_head = currinf.fontp->vf_chain;
  731.           currinf.pos = m->pos;
  732.           currinf.end = m->end;
  733. !         currinf.virtual = currinf.fontp;
  734.           draw_part(current_frame, currinf.fontp->dimconv);
  735.           if (currinf.pos != currinf.end + 1)
  736. !         tell_oops("virtual character macro does not end correctly");
  737.           currinf = oldinfo;
  738.           maxchar = oldmaxchar;
  739.   #ifndef    TEXXET
  740. ***************
  741. *** 553,559 ****
  742.       ubyte    ch;
  743.   {
  744.       if (currinf.virtual) {
  745. !         currinf.fontp = currinf.fontp->first_font;
  746.           if (currinf.fontp != NULL) {
  747.           if (!(currinf.fontp->flags & FONT_LOADED))
  748.               load_font(currinf.fontp);
  749. --- 726,732 ----
  750.       ubyte    ch;
  751.   {
  752.       if (currinf.virtual) {
  753. !         currinf.fontp = currinf.virtual->first_font;
  754.           if (currinf.fontp != NULL) {
  755.           if (!(currinf.fontp->flags & FONT_LOADED))
  756.               load_font(currinf.fontp);
  757. ***************
  758. *** 567,573 ****
  759.   #endif
  760.           }
  761.       }
  762. !     oops("Dvi file or vf macro sets character of unknown font.");
  763.       /* NOTREACHED */
  764.   }
  765.   
  766. --- 740,746 ----
  767.   #endif
  768.           }
  769.       }
  770. !     tell_oops("attempt to set character of unknown font");
  771.       /* NOTREACHED */
  772.   }
  773.   
  774. ***************
  775. *** 639,645 ****
  776.   #ifdef    TEXXET
  777.       struct drawinf    oldinfo;
  778.       ubyte    oldmaxchar;
  779. !     long    file_pos;
  780.       int    refl_count;
  781.   #endif
  782.   
  783. --- 812,818 ----
  784.   #ifdef    TEXXET
  785.       struct drawinf    oldinfo;
  786.       ubyte    oldmaxchar;
  787. !     off_t    file_pos;
  788.       int    refl_count;
  789.   #endif
  790.   
  791. ***************
  792. *** 715,721 ****
  793.   
  794.               case EOP:
  795.               if (current_frame != minframe)
  796. !                 oops("Stack not empty at EOP");
  797.               return;
  798.   
  799.               case PUSH:
  800. --- 888,894 ----
  801.   
  802.               case EOP:
  803.               if (current_frame != minframe)
  804. !                 tell_oops("stack not empty at EOP");
  805.               return;
  806.   
  807.               case PUSH:
  808. ***************
  809. *** 732,738 ****
  810.   
  811.               case POP:
  812.               if (current_frame == minframe)
  813. !                 oops("More POPs than PUSHes");
  814.               currinf.data = current_frame->data;
  815.               current_frame = current_frame->prev;
  816.               break;
  817. --- 905,911 ----
  818.   
  819.               case POP:
  820.               if (current_frame == minframe)
  821. !                 tell_oops("more POPs than PUSHes");
  822.               currinf.data = current_frame->data;
  823.               current_frame = current_frame->prev;
  824.               break;
  825. ***************
  826. *** 744,751 ****
  827.                   oldinfo = currinf;
  828.                   oldmaxchar = maxchar;
  829.                   if (!currinf.virtual)
  830. !                 file_pos = tell(fileno(dvi_file)) -
  831. !                     (currinf.end - currinf.pos);
  832.                   scan_frame = current_frame; /* now we're scanning */
  833.                   refl_count = 0;
  834.                   break;
  835. --- 917,923 ----
  836.                   oldinfo = currinf;
  837.                   oldmaxchar = maxchar;
  838.                   if (!currinf.virtual)
  839. !                 file_pos = xtell(currinf.pos);
  840.                   scan_frame = current_frame; /* now we're scanning */
  841.                   refl_count = 0;
  842.                   break;
  843. ***************
  844. *** 773,780 ****
  845.                   current_frame->data = currinf.data;
  846.                   /* next:  restore old file position, XX, etc. */
  847.                   if (!currinf.virtual) {
  848. !                     long bgn_pos = tell(fileno(dvi_file))
  849. !                      - (currinf.end - dvi_buffer);
  850.                       if (file_pos >= bgn_pos) {
  851.                       oldinfo.pos = dvi_buffer
  852.                           + (file_pos - bgn_pos);
  853. --- 945,952 ----
  854.                   current_frame->data = currinf.data;
  855.                   /* next:  restore old file position, XX, etc. */
  856.                   if (!currinf.virtual) {
  857. !                     off_t bgn_pos = xtell(dvi_buffer);
  858.                       if (file_pos >= bgn_pos) {
  859.                       oldinfo.pos = dvi_buffer
  860.                           + (file_pos - bgn_pos);
  861. ***************
  862. *** 882,896 ****
  863.               xskip((long) xone() + (long) xone());
  864.               break;
  865.   
  866.               case PRE:
  867.               case POST:
  868.               case POSTPOST:
  869. !             oops("Shouldn't happen: %s encountered.",
  870.                   dvi_table2[ch - (FNTNUM0 + 64)]);
  871.               break;
  872.   
  873.               default:
  874. !             oops("Unknown op-code %d", ch);
  875.           } /* end switch*/
  876.           } /* end else (ch not a SETCHAR or FNTNUM) */
  877.       } /* end for */
  878. --- 1054,1072 ----
  879.               xskip((long) xone() + (long) xone());
  880.               break;
  881.   
  882. + #ifndef    TEXXET
  883. +             case SREFL:
  884. +             case EREFL:
  885. + #endif
  886.               case PRE:
  887.               case POST:
  888.               case POSTPOST:
  889. !             tell_oops("shouldn't happen: %s encountered",
  890.                   dvi_table2[ch - (FNTNUM0 + 64)]);
  891.               break;
  892.   
  893.               default:
  894. !             tell_oops("unknown op-code %d", ch);
  895.           } /* end switch*/
  896.           } /* end else (ch not a SETCHAR or FNTNUM) */
  897.       } /* end for */
  898. ***************
  899. *** 912,917 ****
  900.       bzero((char *) &currinf.data, sizeof(currinf.data));
  901.       currinf.tn_head = tn_head;
  902.       currinf.pos = currinf.end = dvi_buffer;
  903. !     currinf.virtual = False;
  904.       draw_part(current_frame = &frame0, dimconv);
  905.   }
  906. --- 1088,1093 ----
  907.       bzero((char *) &currinf.data, sizeof(currinf.data));
  908.       currinf.tn_head = tn_head;
  909.       currinf.pos = currinf.end = dvi_buffer;
  910. !     currinf.virtual = NULL;
  911.       draw_part(current_frame = &frame0, dimconv);
  912.   }
  913. diff -cr xdvi_old/dvi_init.c xdvi_new/dvi_init.c
  914. *** xdvi_old/dvi_init.c    Sat Mar 28 12:50:09 1992
  915. --- xdvi_new/dvi_init.c    Mon Jun  1 16:26:40 1992
  916. ***************
  917. *** 14,19 ****
  918. --- 14,20 ----
  919.    * 4/1989    Modified for System V by Donald Richardson, Clarkson Univ.
  920.    * 3/1990    Added VMS support    --Scott Allendorf, U of Iowa
  921.    * 7/1990    Added reflection mode    --Michael Pak, Hebrew U of Jerusalem
  922. +  * 1/1992    Added greyscale code    --Till Brychcy, Techn. Univ. Muenchen
  923.    *
  924.    *    Compilation options:
  925.    *    SYSV    compile for System V
  926. ***************
  927. *** 27,32 ****
  928. --- 28,34 ----
  929.    *    ALTFONT    default for -altfont option
  930.    *    A4    use European size paper
  931.    *    TEXXET    support reflection dvi codes (right-to-left typesetting)
  932. +  *    GREY    use grey levels to shrink fonts
  933.    */
  934.   
  935.   #include "xdvi.h"
  936. ***************
  937. *** 104,114 ****
  938.   
  939.       for (f = font_head; f != NULL; f = f->next)
  940.           if ((f->flags & FONT_LOADED) && !(f->flags & FONT_VIRTUAL))
  941. !         for (g = f->glyph; g <= f->glyph + f->maxchar; ++g)
  942.               if (g->bitmap2.bits) {
  943.               free(g->bitmap2.bits);
  944.               g->bitmap2.bits = NULL;
  945.               }
  946.   }
  947.   
  948.   /*
  949. --- 106,123 ----
  950.   
  951.       for (f = font_head; f != NULL; f = f->next)
  952.           if ((f->flags & FONT_LOADED) && !(f->flags & FONT_VIRTUAL))
  953. !         for (g = f->glyph; g <= f->glyph + f->maxchar; ++g) {
  954.               if (g->bitmap2.bits) {
  955.               free(g->bitmap2.bits);
  956.               g->bitmap2.bits = NULL;
  957.               }
  958. + #ifdef    GREY
  959. +             if (g->pixmap2) {
  960. +             XDestroyImage(g->image2);
  961. +             g->pixmap2 = NULL;
  962. +             }
  963. + #endif
  964. +         }
  965.   }
  966.   
  967.   /*
  968. ***************
  969. *** 295,302 ****
  970.            *    into SPELL units by multiplying by
  971.            *        (pixels_per_inch * 2**16) / (72.27 * 2**20).
  972.            */
  973. !         fsize = (0.001 * 72.27 * (1<<4)) * vfparent->dimconv * scale
  974. !         / design * magnification;
  975.           scale_dimconv = vfparent->dimconv;
  976.       }
  977.       size = 5 * fsize + 0.5;
  978. --- 304,310 ----
  979.            *    into SPELL units by multiplying by
  980.            *        (pixels_per_inch * 2**16) / (72.27 * 2**20).
  981.            */
  982. !         fsize = (72.27 * (1<<4)) * vfparent->dimconv * scale / design;
  983.           scale_dimconv = vfparent->dimconv;
  984.       }
  985.       size = 5 * fsize + 0.5;
  986. ***************
  987. *** 466,471 ****
  988. --- 474,482 ----
  989.                   g <= fontp->glyph + fontp->maxchar; ++g) {
  990.                   if (g->bitmap.bits != NULL) free(g->bitmap.bits);
  991.                   if (g->bitmap2.bits != NULL) free(g->bitmap2.bits);
  992. + #ifdef    GREY
  993. +                 if (g->pixmap2 != NULL) XDestroyImage(g->image2);
  994. + #endif
  995.               }
  996.               free((char *) fontp->glyph);
  997.               }
  998. diff -cr xdvi_old/font_open.c xdvi_new/font_open.c
  999. *** xdvi_old/font_open.c    Thu Mar 26 18:05:45 1992
  1000. --- xdvi_new/font_open.c    Tue May 19 15:09:48 1992
  1001. ***************
  1002. *** 74,80 ****
  1003. --- 74,83 ----
  1004.   #endif
  1005.   
  1006.   char    *xmalloc(), *getenv();
  1007. + #ifndef    atof
  1008.   double    atof();
  1009. + #endif
  1010.   
  1011.   #ifdef    SEARCH_SUBDIRECTORIES
  1012.   /* We will need some system include files to deal with directories.  */
  1013. ***************
  1014. *** 457,463 ****
  1015.           }
  1016.           else *n++ = c;
  1017.       }
  1018. !     if (!p_used && first_try) return NULL;
  1019.       *n = '\0';
  1020.       if (debug & DBG_OPEN) Printf("Trying font file %s\n", nm);
  1021.       f = xfopen(nm);
  1022. --- 460,466 ----
  1023.           }
  1024.           else *n++ = c;
  1025.       }
  1026. !     if (!p_used && !first_try) return NULL;
  1027.       *n = '\0';
  1028.       if (debug & DBG_OPEN) Printf("Trying font file %s\n", nm);
  1029.       f = xfopen(nm);
  1030. ***************
  1031. *** 571,595 ****
  1032.       return NULL;
  1033.   }
  1034.   
  1035.   /*
  1036.    *    Try a given font name
  1037.    */
  1038.   
  1039.   static    FILE *
  1040. ! pre_font_open(font, mag, mag_ret, name)
  1041.       _Xconst char    *font;
  1042. !     float    mag;
  1043.       int    *mag_ret;
  1044.       char    **name;
  1045.   {
  1046.       FILE    *f;
  1047.       int    *p1, *p2;
  1048. !     int    imag    = mag + 0.5;
  1049. !     int    pxlmag    = 5 * mag + 0.5;
  1050.   #ifndef    VMS
  1051.       _Xconst char    *path_to_use;
  1052.       _Xconst char    *vf_path_to_use;
  1053.   #endif
  1054.   
  1055.       /*
  1056.        * Loop over sizes.  Try actual size first, then closest sizes.
  1057. --- 574,665 ----
  1058.       return NULL;
  1059.   }
  1060.   
  1061. + #ifdef    MAKEPKCMD
  1062. + #define    MAKEPK
  1063. + #endif
  1064. + #ifdef    MAKEPK
  1065. + #ifndef    MAKEPKCMD
  1066. + #define    MAKEPKCMD    "MakeTeXPK"
  1067. + #endif
  1068.   /*
  1069. +  *    Create the string for magstep() values.
  1070. +  */
  1071. + static    char *
  1072. + magstring(mdpi)
  1073. +     int    mdpi;
  1074. + {
  1075. +     int    m;
  1076. +     double    fdpi;
  1077. +     int    tdpi;
  1078. +     static    char    str[24];
  1079. +     if (mdpi != 0) {
  1080. +         fdpi = pixels_per_inch;
  1081. +         m = 0;
  1082. +         if (mdpi >= pixels_per_inch) {
  1083. +         while ((tdpi = fdpi + 0.5) < mdpi) {
  1084. +             fdpi *= 1.095445115;
  1085. +             ++m;
  1086. +         }
  1087. +         if (tdpi == mdpi) {
  1088. +             Sprintf(str, "magstep\\(%d%s\\)", m / 2, m % 2 ? ".5" : "");
  1089. +             return str;
  1090. +         }
  1091. +         }
  1092. +         else {
  1093. +         do {
  1094. +             fdpi *= 0.9128709292;
  1095. +             ++m;
  1096. +         }
  1097. +         while ((tdpi = fdpi + 0.5) > mdpi);
  1098. +         if (tdpi == mdpi) {
  1099. +             Sprintf(str, "magstep\\(-%d%s\\)", m / 2, m % 2 ? ".5" :"");
  1100. +             return str;
  1101. +         }
  1102. +         }
  1103. +     }
  1104. +     Sprintf(str, "%d+%d/%d", mdpi / pixels_per_inch, mdpi % pixels_per_inch,
  1105. +         pixels_per_inch);
  1106. +     return str;
  1107. + }
  1108. + #endif    /* MAKEPK */
  1109. + /*
  1110.    *    Try a given font name
  1111.    */
  1112.   
  1113. + #ifndef    MAKEPK
  1114. + #define    PRE_FONT_OPEN(font, fmag, mag_ret, name, ignore) \
  1115. +         pre_font_open(font, fmag, mag_ret, name)
  1116. + #else
  1117. + #define    PRE_FONT_OPEN    pre_font_open
  1118. + #endif
  1119.   static    FILE *
  1120. ! PRE_FONT_OPEN(font, fmag, mag_ret, name, try_make)
  1121.       _Xconst char    *font;
  1122. !     float    fmag;
  1123.       int    *mag_ret;
  1124.       char    **name;
  1125. + #ifdef    MAKEPK
  1126. +     Boolean    try_make;
  1127. + #endif
  1128.   {
  1129.       FILE    *f;
  1130.       int    *p1, *p2;
  1131. !     int    mag    = 5 * fmag + 0.5;
  1132. !     int    tmag;
  1133.   #ifndef    VMS
  1134.       _Xconst char    *path_to_use;
  1135.       _Xconst char    *vf_path_to_use;
  1136.   #endif
  1137. + #ifdef    MAKEPK
  1138. +     char    mkpk[80];
  1139. + #endif
  1140.   
  1141.       /*
  1142.        * Loop over sizes.  Try actual size first, then closest sizes.
  1143. ***************
  1144. *** 614,646 ****
  1145.   #define    vf_path_to_use    vf_path
  1146.   #endif    /* VMS */
  1147.   
  1148. !     if ((f = try_size(font, *mag_ret = pxlmag, name, path_to_use,
  1149.           default_font_path)) != NULL)
  1150.           return f;
  1151.   
  1152.       /* Try at one away from the size we just tried, to account
  1153.          for rounding error.  */
  1154. !     if (pxlmag < 5 * mag) ++pxlmag; else --pxlmag;
  1155. !     if ((f = try_size(font, *mag_ret = pxlmag, name, path_to_use,
  1156. !         default_font_path)) != NULL)
  1157.           return f;
  1158.   
  1159.       /* Try a virtual font. */
  1160.       if ((f = try_vf(font, name, vf_path_to_use, default_vf_path)) != NULL)
  1161.           return f;
  1162.   
  1163.       /* Now try at all the sizes. */
  1164. !     for (p2 = sizes; p2 < sizend; ++p2) if (*p2 >= pxlmag) break;
  1165.       p1 = p2;
  1166.       for (;;) {
  1167.           /* find another magnification */
  1168.           if (p1 <= sizes)
  1169.           if (p2 >= sizend) return NULL;
  1170. !         else pxlmag = *p2++;
  1171. !         else if (p2 >= sizend || imag * imag <= p1[-1] * *p2)
  1172. !             pxlmag = *--p1;
  1173. !         else pxlmag = *p2++;
  1174. !         if ((f = try_size(font, *mag_ret = pxlmag, name, path_to_use,
  1175.               default_font_path)) != NULL)
  1176.           return f;
  1177.       }
  1178. --- 684,732 ----
  1179.   #define    vf_path_to_use    vf_path
  1180.   #endif    /* VMS */
  1181.   
  1182. !     if ((f = try_size(font, *mag_ret = mag, name, path_to_use,
  1183.           default_font_path)) != NULL)
  1184.           return f;
  1185.   
  1186.       /* Try at one away from the size we just tried, to account
  1187.          for rounding error.  */
  1188. !     tmag = mag + (mag < 5 * fmag ? 1 : -1);
  1189. !     if ((f = try_size(font, tmag, name, path_to_use, default_font_path))
  1190. !         != NULL) {
  1191. !         *mag_ret = tmag;
  1192.           return f;
  1193. +     }
  1194.   
  1195.       /* Try a virtual font. */
  1196.       if ((f = try_vf(font, name, vf_path_to_use, default_vf_path)) != NULL)
  1197.           return f;
  1198.   
  1199. + #ifdef    MAKEPK
  1200. +     /* Try to create the font. */
  1201. +         if (try_make) {
  1202. +         Sprintf(mkpk, "%s %s %d %d %s", MAKEPKCMD, font, mag / 5,
  1203. +         pixels_per_inch, magstring(mag / 5));
  1204. +         Printf("- %s\n", mkpk);
  1205. +         if (system(mkpk) == 0
  1206. +         && (f = try_size(font, mag, name, path_to_use,
  1207. +             default_font_path))
  1208. +             != NULL)
  1209. +         return f;
  1210. +     }
  1211. + #endif
  1212.       /* Now try at all the sizes. */
  1213. !     for (p2 = sizes; p2 < sizend; ++p2) if (*p2 >= mag) break;
  1214.       p1 = p2;
  1215.       for (;;) {
  1216.           /* find another magnification */
  1217.           if (p1 <= sizes)
  1218.           if (p2 >= sizend) return NULL;
  1219. !         else tmag = *p2++;
  1220. !         else if (p2 >= sizend || (long) mag * mag <= (long) p1[-1] * *p2)
  1221. !             tmag = *--p1;
  1222. !         else tmag = *p2++;
  1223. !         if ((f = try_size(font, *mag_ret = tmag, name, path_to_use,
  1224.               default_font_path)) != NULL)
  1225.           return f;
  1226.       }
  1227. ***************
  1228. *** 658,664 ****
  1229.       int    actual_pt, low_pt, high_pt, trial_pt;
  1230.       char    fn[50], *fnend;
  1231.   
  1232. !     f = pre_font_open(font, mag, mag_ret, name);
  1233.       if (f != NULL) {
  1234.           *font_ret = NULL;
  1235.           return f;
  1236. --- 744,750 ----
  1237.       int    actual_pt, low_pt, high_pt, trial_pt;
  1238.       char    fn[50], *fnend;
  1239.   
  1240. !     f = PRE_FONT_OPEN(font, mag, mag_ret, name, True);
  1241.       if (f != NULL) {
  1242.           *font_ret = NULL;
  1243.           return f;
  1244. ***************
  1245. *** 678,685 ****
  1246.           else if (high_pt > actual_pt + 5) break;
  1247.           else trial_pt = high_pt++;
  1248.           Sprintf(fnend, "%d", trial_pt);
  1249. !         f = pre_font_open(fn, mag * actual_pt / trial_pt, mag_ret,
  1250. !             name);
  1251.           if (f != NULL) {
  1252.               *font_ret = strcpy(xmalloc((unsigned) strlen(fn) + 1,
  1253.               "name of font used"), fn);
  1254. --- 764,771 ----
  1255.           else if (high_pt > actual_pt + 5) break;
  1256.           else trial_pt = high_pt++;
  1257.           Sprintf(fnend, "%d", trial_pt);
  1258. !         f = PRE_FONT_OPEN(fn, mag * actual_pt / trial_pt, mag_ret,
  1259. !             name, False);
  1260.           if (f != NULL) {
  1261.               *font_ret = strcpy(xmalloc((unsigned) strlen(fn) + 1,
  1262.               "name of font used"), fn);
  1263. ***************
  1264. *** 688,694 ****
  1265.           }
  1266.       }
  1267.       if (alt_font != NULL) {
  1268. !         f = pre_font_open(alt_font, mag, mag_ret, name);
  1269.           if (f != NULL)
  1270.           *font_ret = strcpy(xmalloc((unsigned) strlen(alt_font) + 1,
  1271.               "name of font used"), alt_font);
  1272. --- 774,780 ----
  1273.           }
  1274.       }
  1275.       if (alt_font != NULL) {
  1276. !         f = PRE_FONT_OPEN(alt_font, mag, mag_ret, name, False);
  1277.           if (f != NULL)
  1278.           *font_ret = strcpy(xmalloc((unsigned) strlen(alt_font) + 1,
  1279.               "name of font used"), alt_font);
  1280. diff -cr xdvi_old/mksedscript xdvi_new/mksedscript
  1281. *** xdvi_old/mksedscript    Thu Dec  5 17:43:12 1991
  1282. --- xdvi_new/mksedscript    Mon Jun  1 16:26:49 1992
  1283. ***************
  1284. *** 7,12 ****
  1285. --- 7,13 ----
  1286.       if ($x == -DA4)        set a4
  1287.       if ($x == -DSEARCH_SUBDIRECTORIES) set subdir
  1288.       if ($x == -DXDVIFONTS_ONLY) set texfonts
  1289. +     if ($x == -DGREY)    set grey
  1290.   end
  1291.   if ($?x10) then
  1292.       echo    /^\#ifx11/,/^\#/d
  1293. ***************
  1294. *** 18,23 ****
  1295. --- 19,25 ----
  1296.   if (! $?buttons)    echo /^\#ifbuttons/,/^\#/d
  1297.   if (! $?subdir)        echo /^\#ifsubdir/,/^\#/d
  1298.   if ($?texfonts)        echo /^\#iftexfonts/,/^\#/d
  1299. + if (! $?grey)        echo /^\#ifgrey/,/^\#/d
  1300.   echo    /^\#/d
  1301.   if ($?a4) then
  1302.       echo    's/%%defaultpagesize%%/21 x 29.7 cm (A4 size)/'
  1303. diff -cr xdvi_old/patchlevel.h xdvi_new/patchlevel.h
  1304. *** xdvi_old/patchlevel.h    Sat Mar 28 00:22:24 1992
  1305. --- xdvi_new/patchlevel.h    Tue Apr  7 12:44:34 1992
  1306. ***************
  1307. *** 1 ****
  1308. ! #define PATCHLEVEL 13
  1309. --- 1 ----
  1310. ! #define PATCHLEVEL 14
  1311. diff -cr xdvi_old/pk.c xdvi_new/pk.c
  1312. *** xdvi_old/pk.c    Thu Jan 23 12:54:49 1992
  1313. --- xdvi_new/pk.c    Thu Apr  9 12:57:16 1992
  1314. ***************
  1315. *** 135,141 ****
  1316.       /*
  1317.        * now read rest of character preamble
  1318.        */
  1319. !     if (n != 4) fpwidth = snum(fp, 3);
  1320.       else {
  1321.           fpwidth = sfour(fp);
  1322.           (void) four(fp);    /* horizontal escapement */
  1323. --- 135,141 ----
  1324.       /*
  1325.        * now read rest of character preamble
  1326.        */
  1327. !     if (n != 4) fpwidth = num(fp, 3);
  1328.       else {
  1329.           fpwidth = sfour(fp);
  1330.           (void) four(fp);    /* horizontal escapement */
  1331. diff -cr xdvi_old/pxl.c xdvi_new/pxl.c
  1332. *** xdvi_old/pxl.c    Mon Mar 23 19:03:00 1992
  1333. --- xdvi_new/pxl.c    Mon Jun  1 16:26:54 1992
  1334. ***************
  1335. *** 119,124 ****
  1336. --- 119,127 ----
  1337.       for (g = fontp->glyph; g < fontp->glyph + 128; ++g) {
  1338.           g->bitmap.bits = NULL;
  1339.           g->bitmap2.bits = NULL;
  1340. + #ifdef    GREY
  1341. +         g->pixmap2 = NULL;
  1342. + #endif
  1343.           g->bitmap.w = two(fp);
  1344.           g->bitmap.h = two(fp);
  1345.           g->x = stwo(fp);
  1346. diff -cr xdvi_old/util.c xdvi_new/util.c
  1347. *** xdvi_old/util.c    Sat Mar 28 12:50:28 1992
  1348. --- xdvi_new/util.c    Mon Jun  1 17:08:35 1992
  1349. ***************
  1350. *** 52,57 ****
  1351. --- 52,61 ----
  1352.   #include <varargs.h>
  1353.   #endif
  1354.   
  1355. + #ifdef    DOPRNT    /* define this if vfprintf gives you trouble */
  1356. + #define    vfprintf(stream, message, args)    _doprnt(message, args, stream)
  1357. + #endif
  1358.   /*
  1359.    *    General utility routines.
  1360.    */
  1361. diff -cr xdvi_old/vf.c xdvi_new/vf.c
  1362. *** xdvi_old/vf.c    Mon Mar 23 19:06:49 1992
  1363. --- xdvi_new/vf.c    Wed Apr 15 17:46:25 1992
  1364. ***************
  1365. *** 53,58 ****
  1366. --- 53,59 ----
  1367.   /*
  1368.    *    Read the fonts.
  1369.    */
  1370. +     fontp->vf_chain = NULL;
  1371.       fontp->first_font = NULL;
  1372.       while ((cmnd = one(VF_file)) >= FNTDEF1 && cmnd <= FNTDEF4) {
  1373.           define_font(VF_file, cmnd, fontp, &fontp->vf_chain);
  1374. diff -cr xdvi_old/xdvi.c xdvi_new/xdvi.c
  1375. *** xdvi_old/xdvi.c    Tue Mar 31 12:23:41 1992
  1376. --- xdvi_new/xdvi.c    Sun Jun  7 11:34:21 1992
  1377. ***************
  1378. *** 14,19 ****
  1379. --- 14,20 ----
  1380.    * 4/1989    Modified for System V by Donald Richardson, Clarkson Univ.
  1381.    * 3/1990    Added VMS support    --Scott Allendorf, U of Iowa
  1382.    * 7/1990    Added reflection mode    --Michael Pak, Hebrew U of Jerusalem
  1383. +  * 1/1992    Added greyscale code    --Till Brychcy, Techn. Univ. Muenchen
  1384.    *
  1385.    *    Compilation options:
  1386.    *    SYSV    compile for System V
  1387. ***************
  1388. *** 27,32 ****
  1389. --- 28,34 ----
  1390.    *    ALTFONT    default for -altfont option
  1391.    *    A4    use European size paper
  1392.    *    TEXXET    support reflection dvi codes (right-to-left typesetting)
  1393. +  *    GREY    use grey levels to shrink fonts
  1394.    */
  1395.   
  1396.   #ifndef    ALTFONT
  1397. ***************
  1398. *** 52,58 ****
  1399.   #define    INIT(x)    =x
  1400.   #include "xdvi.h"
  1401.   
  1402. - #ifndef lint
  1403.   #include "patchlevel.h"
  1404.   static    struct {_Xconst char    a[36], b, c, d;}
  1405.   #ifndef X10
  1406. --- 54,59 ----
  1407. ***************
  1408. *** 62,68 ****
  1409.       header = {"$Header: xdvi.c (X10), patchlevel = ", '0' + PATCHLEVEL / 10,
  1410.           '0' + PATCHLEVEL % 10, 0};
  1411.   #endif
  1412. - #endif    /* lint */
  1413.   
  1414.   #ifndef    X_NOT_STDC_ENV
  1415.   #include <stdlib.h>
  1416. --- 63,68 ----
  1417. ***************
  1418. *** 69,76 ****
  1419.   #endif
  1420.   
  1421.   #ifndef X10
  1422. ! /* Xlib is already included */
  1423. ! #include <X11/Xutil.h>
  1424.   #include <X11/cursorfont.h>
  1425.   #include <X11/keysym.h>
  1426.   #include "xdvi.icon"
  1427. --- 69,75 ----
  1428.   #endif
  1429.   
  1430.   #ifndef X10
  1431. ! /* Xlib and Xutil are already included */
  1432.   #include <X11/cursorfont.h>
  1433.   #include <X11/keysym.h>
  1434.   #include "xdvi.icon"
  1435. ***************
  1436. *** 88,93 ****
  1437. --- 87,93 ----
  1438.   #include <X11/Shell.h>    /* needed for def. of XtNiconX */
  1439.   #ifndef    XtSpecificationRelease
  1440.   #define    XtSpecificationRelease    0
  1441. + #define    XtPointer caddr_t
  1442.   #endif
  1443.   #if    XtSpecificationRelease >= 4
  1444.   #include <X11/Xaw/Viewport.h>
  1445. ***************
  1446. *** 119,127 ****
  1447.   #endif
  1448.   
  1449.   #ifndef X10
  1450.   static    Display    *DISP;
  1451. - #define    DPY    DISP,
  1452.   static    Screen    *SCRN;
  1453.   static    Cursor    redraw_cursor, ready_cursor;
  1454.   
  1455.   #ifdef    VMS
  1456. --- 119,129 ----
  1457.   #endif
  1458.   
  1459.   #ifndef X10
  1460. + #ifndef    GREY
  1461.   static    Display    *DISP;
  1462.   static    Screen    *SCRN;
  1463. + #endif
  1464. + #define    DPY    DISP,
  1465.   static    Cursor    redraw_cursor, ready_cursor;
  1466.   
  1467.   #ifdef    VMS
  1468. ***************
  1469. *** 194,199 ****
  1470. --- 196,202 ----
  1471.   
  1472.   static    int    pageno_correct    = 1;
  1473.   static    Boolean    keep_flag    = False;
  1474. + static    Boolean    version        = False;
  1475.   #ifdef    BUTTONS
  1476.   Boolean    expert        = False;
  1477.   #endif
  1478. ***************
  1479. *** 486,496 ****
  1480. --- 489,539 ----
  1481.   #endif    /* X10 */
  1482.   #endif    /* lint */
  1483.   
  1484. + #ifdef    GREY
  1485. + static    void
  1486. + make_one_pixel_map(pixel, hi)
  1487. +     long pixel[];
  1488. +     int hi;
  1489. + {
  1490. +     int i;
  1491. +     int level;
  1492. +     XColor color;
  1493. +     for (i = 0; i <= hi; i++) {
  1494. +         level = (hi - i) * 65535 / hi;
  1495. +         color.red = color.green = color.blue = level;
  1496. +         color.flags = DoRed | DoGreen | DoBlue;
  1497. +         if (XAllocColor(DISP, DefaultColormapOfScreen(SCRN), &color) == 0)
  1498. +         pixel[i] = (level >= 32768) ? BlackPixelOfScreen(SCRN)
  1499. +                         : WhitePixelOfScreen(SCRN);
  1500. +         else
  1501. +         pixel[i] = color.pixel;
  1502. +     }
  1503. + }
  1504. + static    void
  1505. + init_pix()
  1506. + {
  1507. +     static    Boolean    pixels_allocated = False;
  1508. +     if (pixels_allocated)
  1509. +         return;
  1510. +     make_one_pixel_map(pixel2, 2*2);
  1511. +     make_one_pixel_map(pixel3, 3*3);
  1512. +     make_one_pixel_map(pixel4, 4*4);
  1513. +     pixels_allocated = True;
  1514. + }
  1515. + #endif    /* GREY */
  1516.   #ifdef    sun
  1517.   extern    char    *sprintf();
  1518.   #endif
  1519.   
  1520. + #ifndef    atof    /* on the Next it's a macro */
  1521.   extern    double    atof();
  1522. + #endif
  1523.   
  1524.   /********************************
  1525.    *      tpic routines        *
  1526. ***************
  1527. *** 621,626 ****
  1528. --- 664,694 ----
  1529.       }
  1530.   }
  1531.   
  1532. + #ifdef    GREY
  1533. + void
  1534. + put_image(img, x, y)
  1535. +     register XImage *img;
  1536. +     register int x, y;
  1537. + {
  1538. +     if (x < max_x && x + img->width >= min_x &&
  1539. +         y < max_y && y + img->height >= min_y) {
  1540. +         if (--event_counter == 0) read_events (False);
  1541. +         XPutImage(DISP, WINDOW(currwin), foreGC, img,
  1542. +                 0, 0,
  1543. +             x - currwin.base_x, y - currwin.base_y,
  1544. +             img->width, img->height);
  1545. +         if (foreGC2)
  1546. +         XPutImage(DISP, WINDOW(currwin), foreGC2, img,
  1547. +             0, 0,
  1548. +             x - currwin.base_x, y - currwin.base_y,
  1549. +             img->width, img->height);
  1550. +     }
  1551. + }
  1552. + #endif    /* GREY */
  1553.   /*
  1554.    *    Event-handling routines
  1555.    */
  1556. ***************
  1557. *** 728,734 ****
  1558.   {
  1559.       if (!scrl) XUnmapWindow(DISP, WINDOW(mane));
  1560.       get_xy();
  1561. !     if (page_w > clip_w) {
  1562.           register int coord = (page_w - clip_w) / 2;
  1563.           if (coord > home_x / mane.shrinkfactor)
  1564.           coord = home_x / mane.shrinkfactor;
  1565. --- 796,802 ----
  1566.   {
  1567.       if (!scrl) XUnmapWindow(DISP, WINDOW(mane));
  1568.       get_xy();
  1569. !     if (x_bar != NULL) {
  1570.           register int coord = (page_w - clip_w) / 2;
  1571.           if (coord > home_x / mane.shrinkfactor)
  1572.           coord = home_x / mane.shrinkfactor;
  1573. ***************
  1574. *** 735,741 ****
  1575.           XtCallCallbacks(x_bar, XtNscrollProc,
  1576.           (XtPointer) (window_x + coord));
  1577.       }
  1578. !     if (page_h > clip_h) {
  1579.           register int coord = (page_h - clip_h) / 2;
  1580.           if (coord > home_y / mane.shrinkfactor)
  1581.           coord = home_y / mane.shrinkfactor;
  1582. --- 803,809 ----
  1583.           XtCallCallbacks(x_bar, XtNscrollProc,
  1584.           (XtPointer) (window_x + coord));
  1585.       }
  1586. !     if (y_bar != NULL) {
  1587.           register int coord = (page_h - clip_h) / 2;
  1588.           if (coord > home_y / mane.shrinkfactor)
  1589.           coord = home_y / mane.shrinkfactor;
  1590. ***************
  1591. *** 1212,1219 ****
  1592.       if (windowrec == &alt)
  1593.           if (alt_stat < 0) {    /* destroy upon exposure */
  1594.           alt_stat = 0;
  1595. !         handle_release(widget, (caddr_t) NULL, (XButtonEvent *) event,
  1596. !             (Boolean *) NULL);
  1597.           return;
  1598.           }
  1599.           else
  1600. --- 1280,1286 ----
  1601.       if (windowrec == &alt)
  1602.           if (alt_stat < 0) {    /* destroy upon exposure */
  1603.           alt_stat = 0;
  1604. !         handle_release(widget, (caddr_t) NULL, ev, (Boolean *) NULL);
  1605.           return;
  1606.           }
  1607.           else
  1608. ***************
  1609. *** 1436,1441 ****
  1610. --- 1503,1515 ----
  1611.           reset_fonts();
  1612.           if (mane.shrinkfactor == 1) return;
  1613.           break;
  1614. + #ifdef GREY
  1615. +         case 'G':
  1616. +         use_grey = (arg0 ? number0 : !use_grey);
  1617. +         if (use_grey) init_pix();
  1618. +         reset_fonts();
  1619. +         break;
  1620. + #endif
  1621.           case 'R':
  1622.           /* reread DVI file */
  1623.           --dvi_time;    /* then it will notice a change */
  1624. ***************
  1625. *** 1497,1503 ****
  1626.           if (resized) get_geom();
  1627.           if (event.xany.window == WINDOW(alt) &&
  1628.               event.type == Expose) {
  1629. !         handle_exp((Widget) NULL, &alt, &event.xexpose, (Boolean*)NULL);
  1630.           continue;
  1631.           }
  1632.           if (event.type != KeyPress) {
  1633. --- 1571,1577 ----
  1634.           if (resized) get_geom();
  1635.           if (event.xany.window == WINDOW(alt) &&
  1636.               event.type == Expose) {
  1637. !         handle_exp((Widget) NULL, &alt, &event, (Boolean *) NULL);
  1638.           continue;
  1639.           }
  1640.           if (event.type != KeyPress) {
  1641. ***************
  1642. *** 1837,1843 ****
  1643.       [-expert] [-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
  1644.       [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>]\n\
  1645.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1646. !     [-hushspecials] [-hushchars] [-hush]\n\
  1647.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1648.   [-cr <color>]\n\
  1649.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1650. --- 1911,1917 ----
  1651.       [-expert] [-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
  1652.       [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>]\n\
  1653.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1654. !     [-hushspecials] [-hushchars] [-hush] [-nogrey] [-version]\n\
  1655.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1656.   [-cr <color>]\n\
  1657.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1658. ***************
  1659. *** 1849,1855 ****
  1660.       [-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
  1661.       [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>]\n\
  1662.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1663. !     [-hushspecials] [-hushchars] [-hush]\n\
  1664.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1665.   [-cr <color>]\n\
  1666.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1667. --- 1923,1929 ----
  1668.       [-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
  1669.       [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>]\n\
  1670.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1671. !     [-hushspecials] [-hushchars] [-hush] [-nogrey] [-version]\n\
  1672.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1673.   [-cr <color>]\n\
  1674.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1675. ***************
  1676. *** 1864,1870 ****
  1677.   \n", stderr);
  1678.       Fputs("\
  1679.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1680. !     [-hushspecials] [-hushchars] [-hush]\n\
  1681.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1682.   [-cr <color>]\n\
  1683.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1684. --- 1938,1944 ----
  1685.   \n", stderr);
  1686.       Fputs("\
  1687.       [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>] [-keep]\n\
  1688. !     [-hushspecials] [-hushchars] [-hush] [-nogrey] [-version]\n\
  1689.       [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
  1690.   [-cr <color>]\n\
  1691.       [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
  1692. ***************
  1693. *** 1945,1950 ****
  1694. --- 2019,2026 ----
  1695.   {"+copy",    ".copy",    XrmoptionNoArg,        (caddr_t) "off"},
  1696.   {"-thorough",    ".thorough",    XrmoptionNoArg,        (caddr_t) "on"},
  1697.   {"+thorough",    ".thorough",    XrmoptionNoArg,        (caddr_t) "off"},
  1698. + {"-version",    ".version",    XrmoptionNoArg,        (caddr_t) "on"},
  1699. + {"+version",    ".version",    XrmoptionNoArg,        (caddr_t) "off"},
  1700.   #ifdef    BUTTONS
  1701.   {"-expert",    ".expert",    XrmoptionNoArg,        (caddr_t) "on"},
  1702.   {"+expert",    ".expert",    XrmoptionNoArg,        (caddr_t) "off"},
  1703. ***************
  1704. *** 1955,1960 ****
  1705. --- 2031,2040 ----
  1706.   {"-mgs3",    ".magnifierSize3",XrmoptionSepArg,    (caddr_t) NULL},
  1707.   {"-mgs4",    ".magnifierSize4",XrmoptionSepArg,    (caddr_t) NULL},
  1708.   {"-mgs5",    ".magnifierSize5",XrmoptionSepArg,    (caddr_t) NULL},
  1709. + #ifdef    GREY
  1710. + {"-nogrey",    ".grey",    XrmoptionNoArg,        (caddr_t) "off"},
  1711. + {"+nogrey",    ".grey",    XrmoptionNoArg,        (caddr_t) "on"},
  1712. + #endif
  1713.   };
  1714.   
  1715.   static    XtResource    resources[] = {
  1716. ***************
  1717. *** 2014,2019 ****
  1718. --- 2094,2101 ----
  1719.     (Cardinal)©, XtRBoolean, (caddr_t) ©},
  1720.   {"thorough", "Thorough", XtRBoolean, sizeof(Boolean),
  1721.     (Cardinal)&thorough, XtRBoolean, (caddr_t) &thorough},
  1722. + {"version", "Version", XtRBoolean, sizeof(Boolean),
  1723. +   (Cardinal)&version, XtRBoolean, (caddr_t) &version},
  1724.   #ifdef    BUTTONS
  1725.   {"expert", "Expert", XtRBoolean, sizeof(Boolean),
  1726.     (Cardinal)&expert, XtRBoolean, (caddr_t) &expert},
  1727. ***************
  1728. *** 2028,2033 ****
  1729. --- 2110,2119 ----
  1730.     (Cardinal) &mg_size[3], XtRInt, (caddr_t) &mg_size[3]},
  1731.   {"magnifierSize5", "MagnifierSize", XtRInt, sizeof(int),
  1732.     (Cardinal) &mg_size[4], XtRInt, (caddr_t) &mg_size[4]},
  1733. + #ifdef    GREY
  1734. + {"grey", "Grey", XtRBoolean, sizeof (Boolean),
  1735. +  (Cardinal) &use_grey, XtRBoolean, (caddr_t) &use_grey},
  1736. + #endif
  1737.   };
  1738.   
  1739.   static    Arg    temp_args1[] = {
  1740. ***************
  1741. *** 2148,2153 ****
  1742. --- 2234,2241 ----
  1743.   {"+copy",    "copy",        FalseArg, BooleanArg, 1,(caddr_t) ©},
  1744.   {"-thorough",    NULL,        TrueArg, BooleanArg, 2,    (caddr_t) &thorough},
  1745.   {"+thorough",    "thorough",    FalseArg, BooleanArg, 1,(caddr_t) &thorough},
  1746. + {"-version",    NULL,        TrueArg, BooleanArg, 2,    (caddr_t) &version},
  1747. + {"+version",    "version",    FalseArg, BooleanArg, 1,(caddr_t) &version},
  1748.   #endif    /* X10 */
  1749.   {"-mgs",    NULL,        SepArg, NumberArg, 2,    (caddr_t) &mg_size[0]},
  1750.   {"-mgs1",    "magnifierSize1",SepArg, NumberArg, 1,    (caddr_t) &mg_size[0]},
  1751. ***************
  1752. *** 2157,2162 ****
  1753. --- 2245,2254 ----
  1754.   {"-mgs4",    "magnifierSize4",SepArg, NumberArg, 1,    (caddr_t) &mg_size[3]},
  1755.   {"-mgs5",    "magnifierSize5",SepArg, NumberArg, 1,    (caddr_t) &mg_size[4]},
  1756.   #endif
  1757. + #ifdef    GREY
  1758. + {"-nogrey",    NULL,        FalseArg, BooleanArg, 2,(caddr_t) &use_grey},
  1759. + {"+nogrey",    "grey",        TrueArg, BooleanArg, 1,    (caddr_t) &use_grey},
  1760. + #endif
  1761.   };
  1762.   
  1763.   /*
  1764. ***************
  1765. *** 2478,2484 ****
  1766. --- 2570,2584 ----
  1767.           current_page = (*curr_page ? atoi(curr_page) : total_pages) - 1;
  1768.           if (current_page < 0 || current_page >= total_pages) usage();
  1769.       }
  1770. +     if (version) puts((_Xconst char *) &header);
  1771.   
  1772. + #ifdef    GREY
  1773. +     if (DefaultDepthOfScreen(SCRN) == 1)
  1774. +         use_grey = False;
  1775. +     if (use_grey)
  1776. +         init_pix();
  1777. + #endif
  1778.   #ifndef X10
  1779.   
  1780.       /*
  1781. ***************
  1782. *** 2503,2509 ****
  1783.           XCreateGC(DISP, RootWindowOfScreen(SCRN),\
  1784.               GCFunction|GCForeground|GCBackground, &values))
  1785.   
  1786. !         if (copy == 2) copy = (PlanesOfScreen(SCRN) > 1);
  1787.           if (copy || (set_bits && clr_bits))
  1788.           ruleGC = MakeGC(GXcopy, fore_Pixel, back_Pixel);
  1789.           if (copy) foreGC = ruleGC;
  1790. --- 2603,2609 ----
  1791.           XCreateGC(DISP, RootWindowOfScreen(SCRN),\
  1792.               GCFunction|GCForeground|GCBackground, &values))
  1793.   
  1794. !         if (copy == 2) copy = (DefaultDepthOfScreen(SCRN) > 1);
  1795.           if (copy || (set_bits && clr_bits))
  1796.           ruleGC = MakeGC(GXcopy, fore_Pixel, back_Pixel);
  1797.           if (copy) foreGC = ruleGC;
  1798. diff -cr xdvi_old/xdvi.h xdvi_new/xdvi.h
  1799. *** xdvi_old/xdvi.h    Fri Mar 27 18:15:28 1992
  1800. --- xdvi_new/xdvi.h    Mon Jun  1 16:28:20 1992
  1801. ***************
  1802. *** 8,13 ****
  1803. --- 8,14 ----
  1804.   
  1805.   #ifndef X10
  1806.   #include <X11/Xlib.h>    /* include Xfuncs.h, if available */
  1807. + #include <X11/Xutil.h>    /* needed for XDestroyImage */
  1808.   #include <X11/Xos.h>    /* same as below */
  1809.   #else    /* X10 */
  1810.   #include <X/Xlib.h>    /* get type of Window */
  1811. ***************
  1812. *** 181,187 ****
  1813.       set_char_proc    set_char_p;
  1814.       struct tn    *tn_head;
  1815.       ubyte        *pos, *end;
  1816. !     Boolean        virtual;
  1817.   #ifdef    TEXXET
  1818.       int        dir;
  1819.   #endif
  1820. --- 182,188 ----
  1821.       set_char_proc    set_char_p;
  1822.       struct tn    *tn_head;
  1823.       ubyte        *pos, *end;
  1824. !     struct font    *virtual;
  1825.   #ifdef    TEXXET
  1826.       int        dir;
  1827.   #endif
  1828. ***************
  1829. *** 245,250 ****
  1830. --- 246,255 ----
  1831.       short x, y;        /* x and y offset in pixels */
  1832.       struct bitmap bitmap;    /* bitmap for character */
  1833.       short x2, y2;        /* x and y offset in pixels (shrunken bitmap) */
  1834. + #ifdef    GREY
  1835. +     XImage *image2;
  1836. +     char *pixmap2;
  1837. + #endif
  1838.       struct bitmap bitmap2;    /* shrunken bitmap for character */
  1839.   };
  1840.   
  1841. ***************
  1842. *** 358,363 ****
  1843. --- 363,381 ----
  1844.   
  1845.   EXTERN    jmp_buf    dvi_env;    /* mechanism to communicate dvi file errors */
  1846.   
  1847. + #ifdef    GREY
  1848. + #ifndef    X10
  1849. + EXTERN    Display    *DISP;
  1850. + EXTERN    Screen    *SCRN;
  1851. + EXTERN    long    pixel4[17];
  1852. + EXTERN    long    pixel3[10];
  1853. + EXTERN    long    pixel2[5];
  1854. + EXTERN    Boolean    use_grey    INIT(True);
  1855. + #else    /* Sorry - GREY works only with X11 */
  1856. + #undef    GREY
  1857. + #endif    /* X10 */
  1858. + #endif    /* GREY */
  1859.   /********************************
  1860.    *       Procedures        *
  1861.    *******************************/
  1862. ***************
  1863. *** 369,374 ****
  1864. --- 387,395 ----
  1865.   extern    void    dot_at(int, int);
  1866.   extern    void    do_attribute_path(int, int, int, int);
  1867.   extern    void    put_bitmap(struct bitmap *, int, int);
  1868. + #ifdef    GREY
  1869. + extern    void    put_image(XImage *, int, int);
  1870. + #endif
  1871.   extern    void    put_rectangle(int, int, int, int, WIDEARG(Boolean, int));
  1872.   extern    void    redraw_page(void);
  1873.   #if    NeedVarargsPrototypes
  1874. ***************
  1875. *** 413,418 ****
  1876. --- 434,442 ----
  1877.   extern    void    dot_at();
  1878.   extern    void    do_attribute_path();
  1879.   extern    void    put_bitmap();
  1880. + #ifdef    GREY
  1881. + extern    void    put_image();
  1882. + #endif
  1883.   extern    void    put_rectangle();
  1884.   extern    void    redraw_page();
  1885.   extern    volatile void    oops();
  1886. diff -cr xdvi_old/xdvi_man.sed xdvi_new/xdvi_man.sed
  1887. *** xdvi_old/xdvi_man.sed    Thu Dec  5 17:27:34 1991
  1888. --- xdvi_new/xdvi_man.sed    Sun Jun  7 11:36:01 1992
  1889. ***************
  1890. *** 18,25 ****
  1891. --- 18,28 ----
  1892.   #ifx11
  1893.   [\-geometry \fIgeometry\fP] [\-icongeometry \fIgeometry\fP] [\-iconic]
  1894.   [\-display \fIdisplay\fP] [\-copy] [\-thorough]
  1895. + #endif
  1896.   #ifbuttons
  1897.   [\-expert]
  1898. + #endif
  1899. + [\-version]
  1900.   #ifx10
  1901.   [\-geometry \fIgeometry\fP | =\fIgeometry\fP]
  1902.   [\-display \fIhost\fP:\fIdisplay\fP | \fIhost\fP:\fIdisplay\fP]
  1903. ***************
  1904. *** 179,184 ****
  1905. --- 182,190 ----
  1906.   Prevent the buttons from appearing.  See also the `x' keystroke.
  1907.   #endif
  1908.   .TP
  1909. + .BI \-version
  1910. + Print information on the version of \fIxdvi\fR.
  1911. + .TP
  1912.   .BI \-margins " dimen"
  1913.   (%%dot%%Margin)
  1914.   Specifies the size of both the top margin and side margin.
  1915. ***************
  1916. *** 230,236 ****
  1917. --- 236,251 ----
  1918.   legal (8.5x14), foolscap (13.5x17), as well as the ISO sizes a1-a7,
  1919.   b1-b7, c1-c7, a1r-a7r (a1-a7 rotated), etc.  The default size is
  1920.   %%defaultpagesize%%.
  1921. + #ifgrey
  1922.   .TP
  1923. + .B \-nogrey
  1924. + (.grey)
  1925. + Turns off the use of greyscale anti-aliasing when printing shrunken bitmaps.
  1926. + (In this case, the logic of the corresponding resource is the reverse:
  1927. + -nogrey corresponds to grey:off; +nogrey to grey:on.)
  1928. + See also the `G' keystroke.
  1929. + #endif
  1930. + .TP
  1931.   #ifx11
  1932.   .BI "\-mgs[n]" " size"
  1933.   (.magnifierSize[n])
  1934. ***************
  1935. *** 367,372 ****
  1936. --- 382,394 ----
  1937.   .B x
  1938.   Toggles expert mode (in which the buttons do not appear).  Also `0x' and `1x'
  1939.   clear and reset this mode, respectively.  See also the \fB\-expert\fR option.
  1940. + #endif
  1941. + #ifgrey
  1942. + .TP
  1943. + .B G
  1944. + This key toggles the use of greyscale anti-aliasing for displaying shrunken
  1945. + bitmaps.  In addition, the key sequences `0G' and `1G' clear and
  1946. + set this flag, respectively.  See also the \fB\-nogrey\fR option.
  1947.   #endif
  1948.   .SH MOUSE ACTIONS
  1949.   If the shrink factor is set to any number other than one, then clicking
  1950. -- 
  1951. --
  1952. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1953. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1954. Sunnyvale, California 94086            at&t: 408/522-9236
  1955.