diff -cr dvipsk.orig/Makefile.in dvipsk/Makefile.in
*** dvipsk.orig/Makefile.in	Tue May 28 06:08:07 2002
--- dvipsk/Makefile.in	Mon Jul 22 15:37:54 2002
***************
*** 81,88 ****
  	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mandir) $(infodir) $(psheaderdir)/base
  # PostScript prologues and encodings.
  	for h in $(prologues); do $(INSTALL_DATA) $$h $(psheaderdir)/base/$$h; done
! #	cd $(srcdir)/reencode && \
! #	  for e in *.enc; do $(INSTALL_DATA) $$e $(psheaderdir)/base/$$e; done
  # config.ps. Any one config.ps will be wrong for most people, so don't
  # install anything by default.
  #	if test ! -r $(psheaderdir)/base/config.ps				\
--- 81,88 ----
  	$(SHELL) $(top_srcdir)/../mkinstalldirs $(mandir) $(infodir) $(psheaderdir)/base
  # PostScript prologues and encodings.
  	for h in $(prologues); do $(INSTALL_DATA) $$h $(psheaderdir)/base/$$h; done
! 	cd $(srcdir)/reencode && \
! 	  for e in *.enc; do $(INSTALL_DATA) $$e $(psheaderdir)/base/$$e; done
  # config.ps. Any one config.ps will be wrong for most people, so don't
  # install anything by default.
  #	if test ! -r $(psheaderdir)/base/config.ps				\
***************
*** 91,101 ****
  #          $(INSTALL_DATA) $(srcdir)/config.ps $(psheaderdir)/base/config.ps;	\
  #        else true; fi
  # psfonts.map.
! #	if test ! -r $(psheaderdir)/base/psfonts.map 			\
! #	   || grep 'original psfonts.map --' $(psheaderdir)/base/psfonts.map \
! #	      >/dev/null; then	\
! #	  $(INSTALL_DATA) $(srcdir)/psfonts.map $(psheaderdir)/base/psfonts.map; \
! #        else true; fi
  # Info files.
  	cd $(srcdir) && for i in $(program).i*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
--- 91,101 ----
  #          $(INSTALL_DATA) $(srcdir)/config.ps $(psheaderdir)/base/config.ps;	\
  #        else true; fi
  # psfonts.map.
! 	if test ! -r $(psheaderdir)/base/psfonts.map 			\
! 	   || grep 'original psfonts.map --' $(psheaderdir)/base/psfonts.map \
! 	      >/dev/null; then	\
! 	  $(INSTALL_DATA) $(srcdir)/psfonts.map $(psheaderdir)/base/psfonts.map; \
!         else true; fi
  # Info files.
  	cd $(srcdir) && for i in $(program).i*; do \
  	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
***************
*** 103,110 ****
  	$(INSTALL_DATA) $(srcdir)/dvips.1 $(mandir)/dvips.$(manext)
  	$(INSTALL_DATA) $(srcdir)/afm2tfm.1 $(mandir)/afm2tfm.$(manext)
  # TeX macros.
! #	cd $(srcdir)/tex && for m in *.tex; do \
! #	  $(INSTALL_DATA) $$m $(dvips_plain_macrodir)/$$m; done
  	$(POSTINSTALL)
  	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
  	  install-info --info-dir=$(infodir) $(infodir)/$(program).info; \
--- 103,110 ----
  	$(INSTALL_DATA) $(srcdir)/dvips.1 $(mandir)/dvips.$(manext)
  	$(INSTALL_DATA) $(srcdir)/afm2tfm.1 $(mandir)/afm2tfm.$(manext)
  # TeX macros.
! 	cd $(srcdir)/tex && for m in *.tex; do \
! 	  $(INSTALL_DATA) $$m $(dvips_plain_macrodir)/$$m; done
  	$(POSTINSTALL)
  	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
  	  install-info --info-dir=$(infodir) $(infodir)/$(program).info; \
***************
*** 112,126 ****
  
  uninstall-data:
  	rm -f $(infodir)/dvips.i*
! #	for h in $(prologues); do rm -f $(psheaderdir)/base/$$h; done
! #	cd $(srcdir)/reencode && for e in *.enc; do rm -f $(psheaderdir)/base/$$e; \
! #	  done
! #	if grep 'original config.ps --' $(psheaderdir)/base/config.ps	\
! #             >/dev/null 2>&1; then rm -f $(psheaderdir)/base/config.ps;	\
! #        else true; fi
! #	if grep 'original psfonts.map --' $(psheaderdir)/base/psfonts.map	\
! #              >/dev/null 2>&1; then rm -f $(psheaderdir)/base/psfonts.map;	\
! #        else true; fi
  	rm -f $(mandir)/dvips.$(manext) $(mandir)/afm2tfm.$(manext)
  
  distname = dvipsk
--- 112,126 ----
  
  uninstall-data:
  	rm -f $(infodir)/dvips.i*
! 	for h in $(prologues); do rm -f $(psheaderdir)/base/$$h; done
! 	cd $(srcdir)/reencode && for e in *.enc; do rm -f $(psheaderdir)/base/$$e; \
! 	  done
! 	if grep 'original config.ps --' $(psheaderdir)/base/config.ps	\
!             >/dev/null 2>&1; then rm -f $(psheaderdir)/base/config.ps;	\
!         else true; fi
! 	if grep 'original psfonts.map --' $(psheaderdir)/base/psfonts.map	\
!               >/dev/null 2>&1; then rm -f $(psheaderdir)/base/psfonts.map;	\
!         else true; fi
  	rm -f $(mandir)/dvips.$(manext) $(mandir)/afm2tfm.$(manext)
  
  distname = dvipsk
diff -cr dvipsk.orig/bbox.c dvipsk/bbox.c
*** dvipsk.orig/bbox.c	Wed Feb 17 16:04:06 1999
--- dvipsk/bbox.c	Mon Jul 22 15:37:54 2002
***************
*** 26,36 ****
  } bbfontdesctype ;
  #else
  typedef struct {
!   bbchardesctype bbchardesc[256] ;
  } bbfontdesctype ;
  #endif
  
! static bbfontdesctype *bbaseFonts[256] ;
  integer nscalewidth P2C(register integer, a, register integer, b)
  {
     if (a < 0)
--- 26,36 ----
  } bbfontdesctype ;
  #else
  typedef struct {
!   bbchardesctype bbchardesc[94*120] ;
  } bbfontdesctype ;
  #endif
  
! static bbfontdesctype *bbaseFonts[94*120] ;
  integer nscalewidth P2C(register integer, a, register integer, b)
  {
     if (a < 0)
***************
*** 46,51 ****
--- 46,52 ----
     register shalfword i ;
     register integer li ;
     integer scaledsize ;
+    shalfword id, nt,lf ;
     shalfword nw, nh, nd, ns, hd ;
     shalfword bc, ec ;
  #ifdef Omega
***************
*** 57,62 ****
--- 58,64 ----
     integer scaled[300] ;
     integer chardat[256] ;
  #endif
+    halfword *index, *chartype;
     integer slant = 0 ;
     bbchardesctype *cc ;
     register fontdesctype *curfnt = baseFonts[n] ;
***************
*** 98,104 ****
        }
     }
  #else
!    li = tfm16() ; hd = tfm16() ;
     bc = tfm16() ; ec = tfm16() ;
     nw = tfm16() ; nh = tfm16() ; nd = tfm16() ;
     ns = tfm16() ;
--- 100,115 ----
        }
     }
  #else
!    id = tfm16();
!    if (id == 9 || id == 11) {
!       if (id == 9) curfnt->dir = id ;
!       else curfnt->dir = 0 ;
!       nt = tfm16() ; lf = tfm16() ;
!       curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, sizeof(chardesctype)*(94*120)) ;
!    }
!    else curfnt->dir = 0 ;
! 
!    hd = tfm16() ;
     bc = tfm16() ; ec = tfm16() ;
     nw = tfm16() ; nh = tfm16() ; nd = tfm16() ;
     ns = tfm16() ;
***************
*** 120,125 ****
--- 131,147 ----
                            xmalloc(pretend_no_chars*sizeof(bbchardesctype));
     for (i=0; i<pretend_no_chars; i++)
  #else
+    if (id == 9 || id == 11) {
+       index = (halfword *)malloc(nt * sizeof(halfword)) ;
+       chartype = (halfword *)malloc(nt * sizeof(halfword)) ;
+       li = tfm16() ;
+       li = tfm16() ;
+       for (i=1; i<nt; i++) {
+          li = tfm16() ;
+          index[i] = ((li>>8)-0x21)*94 + (li&0xff)-0x21 ;
+          chartype[i] = tfm16() ;
+       }
+    }
     for (i=0; i<256; i++)
  #endif
        chardat[i] = -1 ;
***************
*** 141,152 ****
     (void)fclose(tfmfile) ;
  #ifdef Omega
     for (i=0; i<pretend_no_chars; i++) {
- #else
-    for (i=0; i<256; i++) {
- #endif
        cc = &(bbcurfnt->bbchardesc[i]) ;
        if (chardat[i] != -1) {
- #ifdef Omega
           if (font_level>=0) {
             cc->ury = scaled[(chardat[i] >> 16) + nw] ;
             cc->lly = - scaled[(chardat[i] & 255) + nw + nh] ;
--- 163,170 ----
***************
*** 154,169 ****
             cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
             cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
           }
- #else
-          cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
-          cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
- #endif
           cc->llx = 0 ;
           cc->urx = curfnt->chardesc[i].TFMwidth ;
        } else {
           cc->llx = cc->lly = cc->urx = cc->ury = 0 ;
        }
     }
     if (slant) {
  #ifdef Omega
        for (i=0; i<pretend_no_chars; i++) {
--- 172,222 ----
             cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
             cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
           }
           cc->llx = 0 ;
           cc->urx = curfnt->chardesc[i].TFMwidth ;
        } else {
           cc->llx = cc->lly = cc->urx = cc->ury = 0 ;
        }
     }
+ #else
+    if (id == 9 || id == 11) {
+       for (i=0; i<94*120; i++) {
+          cc = &(bbcurfnt->bbchardesc[i]) ;
+          if (chardat[0] != -1) {
+             cc->ury = scaled[((chardat[0] >> 4) & 15) + nw] ;
+             cc->lly = - scaled[(chardat[0] & 15) + nw + nh] ;
+             cc->llx = 0 ;
+             cc->urx = curfnt->chardesc[0].TFMwidth ;
+          } else {
+             cc->llx = cc->lly = cc->urx = cc->ury = 0 ;
+          }
+       }
+       for (i=1; i<nt; i++) {
+          cc = &(bbcurfnt->bbchardesc[index[i]]) ;
+          if (chardat[chartype[i]] != -1) {
+             cc->ury = scaled[((chardat[chartype[i]] >> 4) & 15) + nw] ;
+             cc->lly = - scaled[(chardat[chartype[i]] & 15) + nw + nh] ;
+             cc->llx = 0 ;
+             cc->urx = curfnt->chardesc[index[i]].TFMwidth ;
+          } else {
+             cc->llx = cc->lly = cc->urx = cc->ury = 0 ;
+          }
+       }
+    }
+    else {
+       for (i=0; i<256; i++) {
+          cc = &(bbcurfnt->bbchardesc[i]) ;
+          if (chardat[i] != -1) {
+             cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
+             cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
+             cc->llx = 0 ;
+             cc->urx = curfnt->chardesc[i].TFMwidth ;
+          } else {
+             cc->llx = cc->lly = cc->urx = cc->ury = 0 ;
+          }
+       }
+    }
+ #endif
     if (slant) {
  #ifdef Omega
        for (i=0; i<pretend_no_chars; i++) {
***************
*** 178,192 ****
  }
  extern struct dvistack {
    integer hh, vv ;
!   integer h, v, w, x, y, z ;
  } stack[] ;
  static integer llx, lly, urx, ury ;
! void bbspecial P3C(integer, h, integer, v, int, nbytes)
  {
     float *r = bbdospecial(nbytes) ;
     if (r) {
        /* convert from magnified PostScript units back to scaled points */
        real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0 ;
        if (llx > h + r[0] / conv)
           llx = h + r[0] / conv ;
        if (lly > v - r[3] / conv)
--- 231,246 ----
  }
  extern struct dvistack {
    integer hh, vv ;
!   integer h, v, w, x, y, z, dir ;
  } stack[] ;
  static integer llx, lly, urx, ury ;
! void bbspecial P4C(integer, h, integer, v, integer, dir, int, nbytes)
  {
     float *r = bbdospecial(nbytes) ;
     if (r) {
        /* convert from magnified PostScript units back to scaled points */
        real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0 ;
+ #ifdef Omega
        if (llx > h + r[0] / conv)
           llx = h + r[0] / conv ;
        if (lly > v - r[3] / conv)
***************
*** 195,200 ****
--- 249,276 ----
           urx = h + r[2] / conv ;
        if (ury < v - r[1] / conv)
           ury = v - r[1] / conv ;
+ #else
+       if (!dir) {
+          if (llx > h + r[0] / conv)
+             llx = h + r[0] / conv ;
+          if (lly > v - r[3] / conv)
+             lly = v - r[3] / conv ;
+          if (urx < h + r[2] / conv)
+             urx = h + r[2] / conv ;
+          if (ury < v - r[1] / conv)
+             ury = v - r[1] / conv ;
+       }
+       else {
+          if (llx > h + r[1] / conv)
+             llx = h + r[1] / conv ;
+          if (lly > v + r[2] / conv)
+             lly = v + r[2] / conv ;
+          if (urx < h + r[3] / conv)
+             urx = h + r[3] / conv ;
+          if (ury < v + r[0] / conv)
+             ury = v + r[0] / conv ;
+       }
+ #endif
     }
  }
  void bbdopage()
***************
*** 209,219 ****
  #endif
     int charmove ;
     struct dvistack *sp = stack ;
!    integer v, w, x, y, z ;
     register fontdesctype *curfnt = 0 ;
     register bbfontdesctype *bbcurfnt = 0 ;
  
!    w = x = y = z = 0 ;
     h = 0 ; v = 0 ;
     llx = lly = 1000000000 ;
     urx = ury = -1000000000 ;
--- 285,295 ----
  #endif
     int charmove ;
     struct dvistack *sp = stack ;
!    integer v, w, x, y, z, dir ;
     register fontdesctype *curfnt = 0 ;
     register bbfontdesctype *bbcurfnt = 0 ;
  
!    w = x = y = z = dir = 0 ;
     h = 0 ; v = 0 ;
     llx = lly = 1000000000 ;
     urx = ury = -1000000000 ;
***************
*** 261,299 ****
  dochar:
           cd = &(curfnt->chardesc[cmd]) ;
           bcd = &(bbcurfnt->bbchardesc[cmd]) ;
!          if (h + bcd->llx < llx) llx = h + bcd->llx ;
!          if (h + bcd->urx > urx) urx = h + bcd->urx ;
!          if (v - bcd->ury < lly) lly = v - bcd->ury ;
!          if (v - bcd->lly > ury) ury = v - bcd->lly ;
  #endif
           if (charmove)
!             h += cd->TFMwidth ;
           break ;
  #ifdef Omega
  case 130: case 131: case 135: case 136: case 139: 
  #else
! case 129: case 130: case 131: case 134: case 135: case 136: case 139: 
  #endif
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: case 255: /* unimplemented or illegal commands */
           error("! synch") ;
  case 132: case 137: /* rules */
           {  integer ry, rx ;
              ry = signedquad() ; rx = signedquad() ;
              if (rx>0 && ry>0) {
                 if (h < llx) llx = h ;
                 if (v - ry < lly) lly = v - ry ;
                 if (h + rx > urx) urx = h + rx ;
                 if (v > ury) ury = v ;
              } else
                 rx = 0 ;
              if (cmd != 137)
!                h += rx ;
              break ;
           }
  case 141: /* push */
           sp->h = h ; sp->v = v ;
!          sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ;
           if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
           break ;
  case 140: /* eop or end of virtual character */
--- 337,425 ----
  dochar:
           cd = &(curfnt->chardesc[cmd]) ;
           bcd = &(bbcurfnt->bbchardesc[cmd]) ;
!           if (!dir) {
!              if (h + bcd->llx < llx) llx = h + bcd->llx ;
!              if (h + bcd->urx > urx) urx = h + bcd->urx ;
!              if (v - bcd->ury < lly) lly = v - bcd->ury ;
!              if (v - bcd->lly > ury) ury = v - bcd->lly ;
!           } else {
!              if (h + bcd->ury < llx) llx = h + bcd->ury ;
!              if (h + bcd->lly > urx) urx = h + bcd->lly ;
!              if (v + bcd->llx < lly) lly = v + bcd->llx ;
!              if (v + bcd->urx > ury) ury = v + bcd->urx ;
!           }
  #endif
           if (charmove)
!              if (!dir)
!                 h += cd->TFMwidth ;
!              else
!                 v += cd->TFMwidth ;
           break ;
  #ifdef Omega
  case 130: case 131: case 135: case 136: case 139: 
  #else
! case 134: /* put2 */
!          cmd = twobytes() ;
!          charmove = 0 ;
!          goto dochar2 ;
! case 129: cmd = twobytes() ; /* set2 command drops through to setchar */
!          charmove = 1;
! dochar2:
!          if (cmd>=256) cmd = ((cmd>>8)-0x21)*94 + (cmd&0xff)-0x21;
!          cd = &(curfnt->chardesc[cmd]) ;
!          bcd = &(bbcurfnt->bbchardesc[cmd]) ;
!          if (!dir) {
!             if (h + bcd->llx < llx) llx = h + bcd->llx ;
!             if (h + bcd->urx > urx) urx = h + bcd->urx ;
!             if (v - bcd->ury < lly) lly = v - bcd->ury ;
!             if (v - bcd->lly > ury) ury = v - bcd->lly ;
!          } else {
!             if (h + bcd->ury < llx) llx = h + bcd->ury ;
!             if (h + bcd->lly > urx) urx = h + bcd->lly ;
!             if (v + bcd->llx < lly) lly = v + bcd->llx ;
!             if (v + bcd->urx > ury) ury = v + bcd->urx ;
!          }
!          if (charmove)
!             if (!dir)
!                h += cd->TFMwidth ;
!             else
!                v += cd->TFMwidth ;
!          break ;
! case 130: case 131: case 135: case 136: case 139: 
  #endif
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: /* unimplemented or illegal commands */
           error("! synch") ;
+ case 255: /* dir */
+          dir = dvibyte() ;
+          break ;
  case 132: case 137: /* rules */
           {  integer ry, rx ;
              ry = signedquad() ; rx = signedquad() ;
              if (rx>0 && ry>0) {
+             if (!dir) {
                 if (h < llx) llx = h ;
                 if (v - ry < lly) lly = v - ry ;
                 if (h + rx > urx) urx = h + rx ;
                 if (v > ury) ury = v ;
+             } else {
+                if (h < llx) llx = h ;
+                if (v + rx < lly) lly = v + rx ;
+                if (h + ry > urx) urx = h + ry ;
+                if (v > ury) ury = v ;
+             }
              } else
                 rx = 0 ;
              if (cmd != 137)
!                if (!dir)
!                   h += rx ;
!                else
!                   v += rx ;
              break ;
           }
  case 141: /* push */
           sp->h = h ; sp->v = v ;
!          sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; sp->dir = dir ;
           if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
           break ;
  case 140: /* eop or end of virtual character */
***************
*** 301,336 ****
  case 142: /* pop */
           if (--sp < stack) error("! More pops than pushes") ;
           h = sp->h ; v = sp->v ;
!          w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ;
           break ;
! case 143: h += signedbyte() ; break ;
! case 144: h += signedpair() ; break ;
! case 145: h += signedtrio() ; break ;
! case 146: h += signedquad() ; break ;
! case 147: h += w ; break ;
! case 148: h += (w = signedbyte()) ; break ;
! case 149: h += (w = signedpair()) ; break ;
! case 150: h += (w = signedtrio()) ; break ;
! case 151: h += (w = signedquad()) ; break ;
! case 152: h += x ; break ;
! case 153: h += (x = signedbyte()) ; break ;
! case 154: h += (x = signedpair()) ; break ;
! case 155: h += (x = signedtrio()) ; break ;
! case 156: h += (x = signedquad()) ; break ;
! case 157: v += signedbyte() ; break ;
! case 158: v += signedpair() ; break ;
! case 159: v += signedtrio() ; break ;
! case 160: v += signedquad() ; break ;
! case 161: v += y ; break ;
! case 162: v += (y = signedbyte()) ; break ;
! case 163: v += (y = signedpair()) ; break ;
! case 164: v += (y = signedtrio()) ; break ;
! case 165: v += (y = signedquad()) ; break ;
! case 166: v += z ; break ;
! case 167: v += (z = signedbyte()) ; break ;
! case 168: v += (z = signedpair()) ; break ;
! case 169: v += (z = signedtrio()) ; break ;
! case 170: v += (z = signedquad()) ; break ;
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
--- 427,462 ----
  case 142: /* pop */
           if (--sp < stack) error("! More pops than pushes") ;
           h = sp->h ; v = sp->v ;
!          w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; dir = sp->dir ;
           break ;
! case 143: if (!dir) h += signedbyte() ; else v += signedbyte() ; break ;
! case 144: if (!dir) h += signedpair() ; else v += signedpair() ; break ;
! case 145: if (!dir) h += signedtrio() ; else v += signedtrio() ; break ;
! case 146: if (!dir) h += signedquad() ; else v += signedquad() ; break ;
! case 147: if (!dir) h += w ; else v += w ; break ;
! case 148: if (!dir) h += (w = signedbyte()) ; else v += (w = signedbyte()) ; break ;
! case 149: if (!dir) h += (w = signedpair()) ; else v += (w = signedpair()) ; break ;
! case 150: if (!dir) h += (w = signedtrio()) ; else v += (w = signedtrio()) ; break ;
! case 151: if (!dir) h += (w = signedquad()) ; else v += (w = signedquad()) ; break ;
! case 152: if (!dir) h += x ; else v += x ; break ;
! case 153: if (!dir) h += (x = signedbyte()) ; else v += (x = signedbyte()) ; break ;
! case 154: if (!dir) h += (x = signedpair()) ; else v += (x = signedpair()) ; break ;
! case 155: if (!dir) h += (x = signedtrio()) ; else v += (x = signedtrio()) ; break ;
! case 156: if (!dir) h += (x = signedquad()) ; else v += (x = signedquad()) ; break ;
! case 157: if (!dir) v += signedbyte() ; else h -= signedbyte() ; break ;
! case 158: if (!dir) v += signedpair() ; else h -= signedpair() ; break ;
! case 159: if (!dir) v += signedtrio() ; else h -= signedtrio() ; break ;
! case 160: if (!dir) v += signedquad() ; else h -= signedquad() ; break ;
! case 161: if (!dir) v += y ; else h -= y ; break ;
! case 162: if (!dir) v += (y = signedbyte()) ; else h -= (y = signedbyte()) ; break ;
! case 163: if (!dir) v += (y = signedpair()) ; else h -= (y = signedpair()) ; break ;
! case 164: if (!dir) v += (y = signedtrio()) ; else h -= (y = signedtrio()) ; break ;
! case 165: if (!dir) v += (y = signedquad()) ; else h -= (y = signedquad()) ; break ;
! case 166: if (!dir) v += z ; else h += z ; break ;
! case 167: if (!dir) v += (z = signedbyte()) ; else h -= (z = signedbyte()) ; break ;
! case 168: if (!dir) v += (z = signedpair()) ; else h -= (z = signedpair()) ; break ;
! case 169: if (!dir) v += (z = signedtrio()) ; else h -= (z = signedtrio()) ; break ;
! case 170: if (!dir) v += (z = signedquad()) ; else h -= (z = signedquad()) ; break ;
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
***************
*** 358,367 ****
           skipover(cmd - 230) ;
           skipover(dvibyte() + dvibyte()) ;
           break ;
! case 239: bbspecial(h, v, (int)dvibyte()) ; break ;
! case 240: bbspecial(h, v, (int)twobytes()) ; break ;
! case 241: bbspecial(h, v, (int)threebytes()) ; break ;
! case 242: bbspecial(h, v, (int)signedquad()) ; break ;
        }
     }
  }
--- 484,493 ----
           skipover(cmd - 230) ;
           skipover(dvibyte() + dvibyte()) ;
           break ;
! case 239: bbspecial(h, v, dir, (int)dvibyte()) ; break ;
! case 240: bbspecial(h, v, dir, (int)twobytes()) ; break ;
! case 241: bbspecial(h, v, dir, (int)threebytes()) ; break ;
! case 242: bbspecial(h, v, dir, (int)signedquad()) ; break ;
        }
     }
  }
diff -cr dvipsk.orig/color.c dvipsk/color.c
*** dvipsk.orig/color.c	Fri Nov  2 04:26:55 2001
--- dvipsk/color.c	Mon Jul 22 15:49:07 2002
***************
*** 27,33 ****
   */
  #define COLORHASH (89)
  #define MAXCOLORLEN (120)     /* maximum color length for background */
! #define INITCOLORLEN (3000)   /* initial stack size in chars */
  /*
   *   This is where we store the color information for a particular page.
   *   If we free all of these, we free all of the allocated color
--- 27,33 ----
   */
  #define COLORHASH (89)
  #define MAXCOLORLEN (120)     /* maximum color length for background */
! #define INITCOLORLEN (10000)  /* initial stack size in chars */
  /*
   *   This is where we store the color information for a particular page.
   *   If we free all of these, we free all of the allocated color
diff -cr dvipsk.orig/config.ps dvipsk/config.ps
*** dvipsk.orig/config.ps	Wed Nov  4 14:56:08 1998
--- dvipsk/config.ps	Mon Jul 22 15:37:54 2002
***************
*** 67,72 ****
--- 67,84 ----
  @+ %%a3
  @+ %%EndPaperSize
  
+ @ B4 257mm 364mm
+ @+ ! %%DocumentPaperSizes: B4
+ @+ %%BeginPaperSize: B4
+ @+ %%b4
+ @+ %%EndPaperSize
+ 
+ @ B5 182mm 257mm
+ @+ ! %%DocumentPaperSizes: B5
+ @+ %%BeginPaperSize: B5
+ @+ %%b5
+ @+ %%EndPaperSize
+ 
  @ unknown 0in 0in
  @+ statusdict /setpageparams known { hsize vsize 0 1 statusdict begin {
  @+ setpageparams } stopped end } { true } ifelse { statusdict /setpage known
diff -cr dvipsk.orig/dopage.c dvipsk/dopage.c
*** dvipsk.orig/dopage.c	Mon Jun  4 17:17:30 2001
--- dvipsk/dopage.c	Mon Jul 22 15:37:54 2002
***************
*** 16,21 ****
--- 16,23 ----
  extern fontmaptype *ffont ;
  extern quarterword *curpos, *curlim ;
  extern integer hh, vv ;
+ integer dir ;
+ extern integer rdir, fdir ;
  extern integer hoff, voff ;
  /*
   * CONVENTION:  conv -> horizontial converter
***************
*** 32,46 ****
  extern int vmaxdrift ;
  
  #ifdef XENIX
! #define PixRound(x) ((integer)(x + (iconv >> 1)) / iconv)
! #define VPixRound(x) ((integer)(x + (viconv >> 1)) / viconv)
  #else
  #ifdef __THINK__
! #define  PixRound(x) ((integer)(x +  (iconv >> 1)) /  iconv)
! #define VPixRound(x) ((integer)(x + (viconv >> 1)) / viconv)
  #else
! #define PixRound(x) ((integer)(floor(((x) * conv) + 0.5)))
! #define VPixRound(x) ((integer)(floor(((x) * vconv) + 0.5)))
  #endif
  #endif
  /*
--- 34,52 ----
  extern int vmaxdrift ;
  
  #ifdef XENIX
! #define PixRound(x) dir ? ((integer)(x + (viconv >> 1)) / viconv) : ((integer)(x + (iconv >> 1)) / iconv)
! #define VPixRound(x) dir ? ((integer)(x + (iconv >> 1)) / iconv) : ((integer)(x + (viconv >> 1)) / viconv)
  #else
  #ifdef __THINK__
! #define  PixRound(x) dir ? ((integer)(x + (viconv >> 1)) / viconv) : ((integer)(x + (iconv >> 1)) / iconv)
! #define VPixRound(x) dir ? ((integer)(x + (iconv >> 1)) / iconv) : ((integer)(x + (viconv >> 1)) / viconv)
  #else
! /*
! #define PixRound(x) dir ? ((integer)(floor(((x) * vconv) + 0.5))) : ((integer)(floor(((x) * conv) + 0.5)))
! #define VPixRound(x) dir ? ((integer)(floor(((x) * conv) + 0.5))) : ((integer)(floor(((x) * vconv) + 0.5)))
! */
! #define PixRound(x) dir ? ((integer)(floor(((x) * vconv) + 0.5))) : ((integer)(floor(((x) * conv) + 0.5)))
! #define VPixRound(x) dir ? ((integer)(floor(((x) * conv) + 0.5))) : ((integer)(floor(((x) * vconv) + 0.5)))
  #endif
  #endif
  /*
***************
*** 50,56 ****
   */
  struct dvistack {
    integer hh, vv ;
!   integer h, v, w, x, y, z ;
  } stack[STACKSIZE] ;
  #ifdef HPS
  extern int pagecounter ;
--- 56,62 ----
   */
  struct dvistack {
    integer hh, vv ;
!   integer h, v, w, x, y, z, dir ;
  } stack[STACKSIZE] ;
  #ifdef HPS
  extern int pagecounter ;
***************
*** 68,74 ****
  void
  dopage P1H(void)
  {
!    register shalfword cmd ;
     register integer p ;
     register chardesctype *cd ;
     register integer h ;
--- 74,81 ----
  void
  dopage P1H(void)
  {
!    register i ;
!    register unsigned short cmd ;
     register integer p ;
     register chardesctype *cd ;
     register integer h ;
***************
*** 111,117 ****
     if (HPS_FLAG) pagecounter++ ;
     H_BREAK = (30 * DPI / 400 ) ; /* 30 seems to have worked well at 400 dpi */
  #endif 
!    w = x = y = z = 0 ;
     h = DPI / conv * hoff / 4736286.72 ;
     v = DPI / conv * voff / 4736286.72 ;
     hh = PixRound(h) ;
--- 118,124 ----
     if (HPS_FLAG) pagecounter++ ;
     H_BREAK = (30 * DPI / 400 ) ; /* 30 seems to have worked well at 400 dpi */
  #endif 
!    w = x = y = z = dir = rdir = fdir = 0 ;
     h = DPI / conv * hoff / 4736286.72 ;
     v = DPI / conv * voff / 4736286.72 ;
     hh = PixRound(h) ;
***************
*** 178,190 ****
     if (cd->flags & EXISTS) {
        if (curfnt->loaded == 2) { /* virtual character being typeset */
           if (charmove) {
!             sp->hh = hh + cd->pixelwidth ;
!             sp->h = h + cd->TFMwidth ;
           } else {
              sp->hh = hh ; sp->h = h ;
           }
!          sp->vv = vv ; sp-> v = v ;
!          sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ;
           if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
           w = x = y = z = 0 ; /* will be in relative units at new stack level */
           frp->curp = curpos ;
--- 185,210 ----
     if (cd->flags & EXISTS) {
        if (curfnt->loaded == 2) { /* virtual character being typeset */
           if (charmove) {
!             if (!dir) {
!                sp->h = h + cd->TFMwidth ;
!                sp->hh = PixRound(sp->h) ;
!             } else {
!                sp->v = v + cd->TFMwidth ;
!                sp->vv = PixRound(sp->v) ;
!             }
!          } else {
!             if (!dir) {
!                sp->hh = hh ; sp->h = h ;
!             } else {
!                sp->vv = vv ; sp->v = v ;
!             }
!          }
!          if (!dir) {
!             sp->vv = vv ; sp->v = v ;
           } else {
              sp->hh = hh ; sp->h = h ;
           }
!          sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; sp->dir = dir ;
           if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
           w = x = y = z = 0 ; /* will be in relative units at new stack level */
           frp->curp = curpos ;
***************
*** 212,229 ****
  #endif
     }
     if (charmove) {
!       h += cd->TFMwidth ;
!       hh += cd->pixelwidth ;
     }
     goto setmotion ;
  #ifdef Omega
  case 130: case 131: case 135: case 136: case 139: 
  #else
! case 129: case 130: case 131: case 134: case 135: case 136: case 139: 
  #endif
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: case 255: /* unimplemented or illegal commands */
     error("! synch") ;
  case 132: case 137: /* rules */
   { integer ry, rx , rxx, ryy ;
     ry = signedquad() ; rx = signedquad() ;
--- 232,323 ----
  #endif
     }
     if (charmove) {
!       if (!dir) {
!          h += cd->TFMwidth ;
!          hh += cd->pixelwidth ;
!       } else {
!          v += cd->TFMwidth ;
!          vv += cd->pixelwidth ;
!       }
     }
     goto setmotion ;
  #ifdef Omega
  case 130: case 131: case 135: case 136: case 139: 
  #else
! case 134: /* put2 */
!    cmd = twobytes() ;
!    charmove = 0 ;
!    goto dochar2 ;
! case 129: cmd = twobytes() ; /* set2 command drops through to setchar */
!    charmove = 1 ;
! dochar2:
!    if (cmd>=256) cmd = ((cmd>>8)-0x21)*94 + (cmd&0xff)-0x21;
!    cd = &(curfnt->chardesc[cmd]) ;
!    if (cd->flags & EXISTS) {
!       if (curfnt->loaded == 2) { /* virtual character being typeset */
!          if (charmove) {
!             if (!dir) {
!                sp->h = h + cd->TFMwidth ;
!                sp->hh = PixRound(sp->h) ;
!             } else {
!                sp->v = v + cd->TFMwidth ;
!                sp->vv = PixRound(sp->v) ;
!             }
!          } else {
!             if (!dir) {
!                sp->hh = hh ; sp->h = h ;
!             } else {
!                sp->vv = vv ; sp->v = v ;
!             }
!          }
!          if (!dir) {
!             sp->vv = vv ; sp-> v = v ;
!          } else {
!             sp->hh = hh ; sp-> h = h ;
!          }
!          sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; sp->dir = dir ;
!          if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
!          w = x = y = z = 0 ; /* will be in relative units at new stack level */
!          frp->curp = curpos ;
!          frp->curl = curlim ;
!          frp->ff = ffont ;
!          frp->curf = curfnt ;
!          if (++frp == &frames[MAXFRAME] )
!             error("! virtual recursion stack overflow") ;
!          curpos = cd->packptr + 2 ;
!          curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ;
!          ffont = curfnt->localfonts ;
!          if (ffont) {
!             curfnt = ffont->desc ;
!             thinspace = curfnt->thinspace ;
!          } else {
!             curfnt = NULL ;
!             thinspace = vertsmallspace ;
!          }
!          goto beginloop ;
!       }
!       drawchar(cd, (cmd/94+0x21)*256 + (cmd%94) + 0x21) ;
!    }
!    if (charmove) {
!       if (!dir) {
!          h += cd->TFMwidth ;
!          hh = PixRound(h);
!       } else {
!          v += cd->TFMwidth ;
!          vv = PixRound(v);
!       }
!    }
!    goto setmotion ;
! 
! case 130: case 131: case 135: case 136: case 139: 
  #endif
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: /* unimplemented or illegal commands */
     error("! synch") ;
+ case 255: /* dir */
+    dir = dvibyte() ;
+    cmddir();
+    goto beginloop ;
  case 132: case 137: /* rules */
   { integer ry, rx , rxx, ryy ;
     ry = signedquad() ; rx = signedquad() ;
***************
*** 232,244 ****
           rx = scalewidth(rx, (frp-1)->curf->scaledsize) ;
           ry = scalewidth(ry, (frp-1)->curf->scaledsize) ;
        }
!       rxx = (int)(conv * rx + 0.9999999) ;
!       ryy = (int)(vconv * ry + 0.9999999) ;
        drawrule(rxx, ryy) ;
     } else
        rxx = 0 ;
     if (cmd == 137) goto beginloop ;
!    h += rx ; hh += rxx ;
     goto setmotion ;
   }
  case 141: /* push */
--- 326,349 ----
           rx = scalewidth(rx, (frp-1)->curf->scaledsize) ;
           ry = scalewidth(ry, (frp-1)->curf->scaledsize) ;
        }
!       if (!dir) {
!         rxx = (int)(conv * rx + 0.9999999) ;
!         ryy = (int)(vconv * ry + 0.9999999) ;
!       }
!       else {
!         rxx = (int)(vconv * rx + 0.9999999) ;
!         ryy = (int)(conv * ry + 0.9999999) ;
!       }
        drawrule(rxx, ryy) ;
     } else
        rxx = 0 ;
     if (cmd == 137) goto beginloop ;
!    if (!dir) {
!      h += rx ; hh += rxx ;
!    }
!    else {
!      v += rx ; vv += rxx ;
!    }
     goto setmotion ;
   }
  case 141: /* push */
***************
*** 256,262 ****
      /* printf("push %i, %i\n", pushcount, inHTMLregion) ; */
  #endif
     sp->hh = hh ; sp->vv = vv ; sp->h = h ; sp->v = v ;
!    sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ;
     if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
     goto beginloop ;
  case 140: /* eop or end of virtual character */
--- 361,367 ----
      /* printf("push %i, %i\n", pushcount, inHTMLregion) ; */
  #endif
     sp->hh = hh ; sp->vv = vv ; sp->h = h ; sp->v = v ;
!    sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; sp->dir = dir ;
     if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ;
     goto beginloop ;
  case 140: /* eop or end of virtual character */
***************
*** 288,299 ****
       }
  #endif
     hh = sp->hh ; vv = sp->vv ; h = sp->h ; v = sp->v ; 
!    w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ;
  #ifdef HPS
     if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) &&
         (pushcount < current_pushcount)) 
       end_current_box() ;
  #endif
     goto beginloop ;
  case 143: /* right1 */
     p = signedbyte() ; goto horizontalmotion ;
--- 393,405 ----
       }
  #endif
     hh = sp->hh ; vv = sp->vv ; h = sp->h ; v = sp->v ; 
!    w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; dir = sp->dir ;
  #ifdef HPS
     if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) &&
         (pushcount < current_pushcount)) 
       end_current_box() ;
  #endif
+    cmddir();
     goto beginloop ;
  case 143: /* right1 */
     p = signedbyte() ; goto horizontalmotion ;
***************
*** 407,412 ****
--- 513,519 ----
  /* vertical motion cases */
        if (curpos)
           p = scalewidth(p, (frp-1)->curf->scaledsize) ;
+    if (!dir) {
        v += p ;
        if (p >= vertsmallspace) vv = VPixRound(v) ;
        else if (p <= -vertsmallspace) vv = VPixRound(v) ;
***************
*** 416,421 ****
--- 523,539 ----
          if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift ;
          else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift ;
        }
+    } else {
+       h -= p ;
+       if (p >= vertsmallspace) hh = VPixRound(h) ;
+       else if (p <= -vertsmallspace) hh = VPixRound(h) ;
+       else 
+       { hh -= VPixRound(p) ;
+         roundpos = VPixRound(h) ;
+         if (roundpos - hh > vmaxdrift) hh = roundpos - vmaxdrift ;
+         else if (hh - roundpos > vmaxdrift) hh = roundpos + vmaxdrift ;
+       }
+    }
  #ifdef HPS
     /* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */
  		/* printf("inHTMLregion %i\n", inHTMLregion) ; */
***************
*** 432,449 ****
--- 550,581 ----
  /* horizontal motion cases */
        if (curpos)
           p = scalewidth(p, (frp-1)->curf->scaledsize) ;
+    if (!dir) {
        h += p ;
        if (p >= thinspace || p <= -6 * thinspace) {
           hh = PixRound(h) ; goto beginloop ;
        }
        else hh += PixRound(p) ;
+    } else {
+       v += p ;
+       if (p >= thinspace || p <= -6 * thinspace) {
+          vv = PixRound(v) ; goto beginloop ;
+       }
+       else vv += PixRound(p) ;
+    }
  #ifdef HPS
      /* printf("Doing horizontal motion: p = %i, h = %i, hh = %i\n",p,h,hh); */
  #endif
  setmotion:
+    if (!dir) {
        roundpos = PixRound(h) ;
        if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift ; }
        else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift ; }
+    } else {
+       roundpos = PixRound(v) ;
+       if (roundpos - vv > maxdrift) { vv = roundpos - maxdrift ; }
+       else if (vv - roundpos > maxdrift) { vv = roundpos + maxdrift ; }
+    }
  goto beginloop ;
  
     } /* end of the big switch */
diff -cr dvipsk.orig/dospecial.c dvipsk/dospecial.c
*** dvipsk.orig/dospecial.c	Fri Nov  2 04:27:18 2001
--- dvipsk/dospecial.c	Mon Jul 22 15:37:54 2002
***************
*** 119,124 ****
--- 119,174 ----
     }
  }
  
+ /* added for dvi2ps & jdvi2kps format */
+ static void
+ fgetboundingbox(f, llx_p, lly_p, urx_p, ury_p)
+ char *f;
+ float *llx_p;
+ float *lly_p;
+ float *urx_p;
+ float *ury_p;
+ {
+ 	FILE *fp;
+ 	char buf[BUFSIZ];
+ 	fp = search(figpath, f, READ);
+ 	if (fp == 0)
+ 		fp = search(headerpath, f, READ);
+ 	if (fp) {
+ 		while (fgets(buf, BUFSIZ, fp) != 0) {
+ 			if (buf[0] == '%' && buf[1] == '%'
+ 			 && strncmp(buf+2, "BoundingBox:", 12) == 0) {
+ 				if (sscanf(buf+14, "%f %f %f %f",
+ 						llx_p, lly_p, urx_p, ury_p) == 4) {
+ 					fclose(fp);
+ 					return;
+ 				}
+ 			}
+ 		}
+ 		fclose(fp);
+ 	}
+ 	sprintf(errbuf, "Couldn't get BoundingBox of %s: assuming full A4 size", f);
+ 	specerror(errbuf);
+ 	*llx_p = 0.0;
+ 	*lly_p = 0.0;
+ 	*urx_p = 595.0;
+ 	*ury_p = 842.0;
+ 	return;
+ }
+ 
+ static void
+ floatroundout(f)
+ float f;
+ {
+ 	integer i;
+ 	i = (integer)(f<0 ? f-0.5 : f+0.5);
+ 	if (i-f < 0.001 && i-f > -0.001) {
+ 		numout((integer)i);
+ 	} else {
+ 		floatout(f);
+ 	}
+ }
+ /* end addition */
+ 
  void
  outbangspecials P1H(void) {
     if (bangspecials) {
***************
*** 506,511 ****
--- 556,615 ----
  	emspecial(p);
  	return;
     }
+ /* added for dvi2ps format */
+ 	if (strncmp(p, "epsfile=", 8)==0) {  /* epsf.sty for dvi2ps-j */
+ 	 float llx, lly, urx, ury;
+ 
+ 		p += 8;
+ 		sscanf(p, "%s", psfile);
+ 		p += strlen(psfile);
+ 		fgetboundingbox(psfile, &llx, &lly, &urx, &ury);
+ 		hvpos();
+ 		cmdout("@beginspecial");
+ 		floatroundout(llx);
+ 		cmdout("@llx");
+ 		floatroundout(lly);
+ 		cmdout("@lly");
+ 		floatroundout(urx);
+ 		cmdout("@urx");
+ 		floatroundout(ury);
+ 		cmdout("@ury");
+ 
+ 		while (p = GetKeyVal(p, &j)) {
+ 			switch (j) {
+ 			  case 3: /* hsize */
+ 				floatroundout(ValNum*10);
+ 				cmdout("@rwi");
+ 				break;
+ 			  case 4: /* vsize */
+ 				floatroundout(ValNum*10);
+ 				cmdout("@rhi");
+ 				break;
+ 			  case 7: /* hscale */
+ 				floatroundout((urx-llx)*ValNum*10);
+ 				cmdout("@rwi");
+ 				break;
+ 			  case 8: /* vscale */
+ 					floatroundout((ury-lly)*ValNum*10);
+ 					cmdout("@rhi");
+ 					break;
+ 			  default:
+ 				sprintf(errbuf, "Unknown keyword `%s' in \\special{epsfile=%s...} will be ignored\n", KeyStr, psfile);
+ 				specerror(errbuf);
+ 				break;
+ 			}
+ 		}
+ 		cmdout("@setspecial");
+ 		numout((integer)0);
+ 		cmdout("lly");
+ 		cmdout("ury");
+ 		cmdout("sub");
+ 		cmdout("TR");
+ 		figcopyfile(psfile, 0);
+ 		cmdout("\n@endspecial");
+ 		return;
+ 	}
+ /* end addition */
     break ;
  case 'p':
     if (strncmp(p, "pos:", 4)==0) return ; /* positional specials */
***************
*** 553,558 ****
--- 657,689 ----
     if (strncmp(p, "pn ", 3) == 0) {setPenSize(p+2); return;}
     if (strncmp(p, "pa ", 3) == 0) {addPath(p+2); return;}
  #endif
+ /* added for jdvi2kps format */
+ 	if (strncmp(p, "postscriptbox", 13)==0) { /* epsbox.sty for jdvi2kps */
+ 		float w, h;
+ 		float llx, lly, urx, ury;
+ 		if (sscanf(p+13, "{%fpt}{%fpt}{%[^}]}", &w, &h, psfile) != 3)
+ 			break;
+ 		fgetboundingbox(psfile, &llx, &lly, &urx, &ury);
+ 		hvpos();
+ 		cmdout("@beginspecial");
+ 		floatroundout(llx);
+ 		cmdout("@llx");
+ 		floatroundout(lly);
+ 		cmdout("@lly");
+ 		floatroundout(urx);
+ 		cmdout("@urx");
+ 		floatroundout(ury);
+ 		cmdout("@ury");
+ 		floatroundout(w*10*72/72.27);
+ 		cmdout("@rwi");
+ 		floatroundout(h*10*72/72.27);
+ 		cmdout("@rhi");
+ 		cmdout("@setspecial");
+ 		figcopyfile(psfile, 0);
+ 		cmdout("\n@endspecial");
+ 		return;
+ 	}
+ /* end addition */
     break ;
  case 'l':
     if (strncmp(p, "landscape", 9)==0) return ;
diff -cr dvipsk.orig/download.c dvipsk/download.c
*** dvipsk.orig/download.c	Tue May 28 06:08:07 2002
--- dvipsk/download.c	Mon Jul 22 15:37:54 2002
***************
*** 222,232 ****
--- 222,234 ----
     curfnt->psname = psfont ;
     if (curfnt->resfont) {
        struct resfont *rf = curfnt->resfont ;
+ /*
        for (b=0; b<16; b++)
          if(p->bitmap[b] !=0)
              non_empty =1;
        if(non_empty==0)
          return;
+ */
        cmdout(name) ;
  /* following code re-arranged - Rob Hutchings 1992Apr02 */
        c = curfnt->chardesc + 255 ;
***************
*** 246,252 ****
--- 248,256 ----
                 numcc++ ;
              } else {
                 i++ ;
+ /*
                 c->flags &= ~EXISTS ;
+ */
              }
              c-- ;
              cc-- ;
diff -cr dvipsk.orig/drawPS.c dvipsk/drawPS.c
*** dvipsk.orig/drawPS.c	Sun Nov  1 12:45:06 1998
--- dvipsk/drawPS.c	Mon Jul 22 15:37:54 2002
***************
*** 97,102 ****
--- 97,103 ----
   * external variables used here
   */
  extern integer hh,vv;           /* the current x,y position in pixel units */
+ extern integer dir;
  extern int actualdpi ;
  extern int vactualdpi ;
  extern double mag ;
***************
*** 111,123 ****
  
  /* convert from tpic units to PS units */
  #define PixRound(a,b) zPixRound((integer)(a),(integer)(b))
! #define convPS(x) PixRound((x),convRESOLUTION)
! #define convVPS(x) PixRound((x),convVRESOLUTION)
  
  /* convert from tpic locn to abs horiz PS locn */
! #define hconvPS(x) (integer)(hh + convPS(x))
  /* convert from tpic locn to abs vert PS locn */
! #define vconvPS(x) (integer)(vv + convVPS(x))
  /* convert to degrees */
  #define convDeg(x) (360*(x)/(2*3.14159265358))
  
--- 112,126 ----
  
  /* convert from tpic units to PS units */
  #define PixRound(a,b) zPixRound((integer)(a),(integer)(b))
! #define convPS(x) PixRound((x),dir ? convVRESOLUTION : convRESOLUTION)
! #define convVPS(x) PixRound((x),dir? convRESOLUTION : convVRESOLUTION)
! #define ConvPS(x) PixRound((x),convRESOLUTION)
! #define ConvVPS(x) PixRound((x),convVRESOLUTION)
  
  /* convert from tpic locn to abs horiz PS locn */
! #define hconvPS(x) dir ? (integer)(vv + ConvVPS(x)) : (integer)(hh + ConvPS(x))
  /* convert from tpic locn to abs vert PS locn */
! #define vconvPS(x) dir ? (integer)(-hh + ConvPS(x)) : (integer)(vv + ConvVPS(x))
  /* convert to degrees */
  #define convDeg(x) (360*(x)/(2*3.14159265358))
  
***************
*** 211,218 ****
        numout((integer)hconvPS(xc));
        numout((integer)vconvPS(yc));
        numout((integer)convPS(xrad));
!       if (xrad != yrad && VDPI == DPI)
! 	numout((integer)convPS(yrad));
        floatout(convDeg(startAngle));
        floatout(convDeg(endAngle));
  
--- 214,221 ----
        numout((integer)hconvPS(xc));
        numout((integer)vconvPS(yc));
        numout((integer)convPS(xrad));
!       if (xrad != yrad || VDPI != DPI)
! 	numout((integer)convVPS(yrad));
        floatout(convDeg(startAngle));
        floatout(convDeg(endAngle));
  
***************
*** 243,254 ****
  	  numout((integer)hconvPS(xc));
  	  numout((integer)vconvPS(yc));
  	  numout((integer)convPS(xrad));
! 	  if (xrad != yrad)
! 	      numout((integer)convPS(yrad));
  	  floatout(degStAng);
  	  floatout(degEnAng);
  
! 	  if (xrad == yrad)	/* for arcs and circles */
  	      cmdout("arc");
  	  else
  	      cmdout("ellipse");
--- 246,257 ----
  	  numout((integer)hconvPS(xc));
  	  numout((integer)vconvPS(yc));
  	  numout((integer)convPS(xrad));
!       if (xrad != yrad || VDPI != DPI)
! 	      numout((integer)convVPS(yrad));
  	  floatout(degStAng);
  	  floatout(degEnAng);
  
!       if (xrad == yrad && VDPI == DPI)		/* for arcs and circles */
  	      cmdout("arc");
  	  else
  	      cmdout("ellipse");
***************
*** 471,477 ****
  void
  flushSpline P1C(char *, cp)
  {                               /* as exact as psdit!!! */
!   register long i, dxi, dyi, dxi1, dyi1;
  
    if (*cp) {
        float inchesPerDash;
--- 474,480 ----
  void
  flushSpline P1C(char *, cp)
  {                               /* as exact as psdit!!! */
!   register long i, px, py, dx, dy;
  
    if (*cp) {
        float inchesPerDash;
***************
*** 508,530 ****
    numout((integer)hconvPS(xx[1]));
    numout((integer)vconvPS(yy[1]));
    cmdout(MOVETO);
!   numout((integer)convPS((xx[2]-xx[1])/2));
!   numout((integer)convPS((yy[2]-yy[1])/2));
    cmdout(RLINETO);
  
    for (i=2; i < pathLen; i++)
      {
!       dxi = convPS(xx[i] - xx[i-1]);
!       dyi = convVPS(yy[i] - yy[i-1]);
!       dxi1 = convPS(xx[i+1] - xx[i]);
!       dyi1 = convVPS(yy[i+1] - yy[i]);
! 
!       numout((integer)dxi/3);
!       numout((integer)dyi/3);
!       numout((integer)(3*dxi+dxi1)/6);
!       numout((integer)(3*dyi+dyi1)/6);
!       numout((integer)(dxi+dxi1)/2);
!       numout((integer)(dyi+dyi1)/2);
        cmdout(RCURVETO);
      }
  
--- 511,534 ----
    numout((integer)hconvPS(xx[1]));
    numout((integer)vconvPS(yy[1]));
    cmdout(MOVETO);
!   px = (integer)convPS(xx[1]);
!   py = (integer)convVPS(yy[1]);
!   numout(dx = (integer)convPS((xx[2]+xx[1])/2) - px);
!   numout(dy = (integer)convVPS((yy[2]+yy[1])/2) - py);
!   px += dx;
!   py += dy;
    cmdout(RLINETO);
  
    for (i=2; i < pathLen; i++)
      {
!       numout((integer)convPS((xx[i-1]+5*xx[i])/6) - px);
!       numout((integer)convVPS((yy[i-1]+5*yy[i])/6) - py);
!       numout((integer)convPS((5*xx[i]+xx[i+1])/6) - px);
!       numout((integer)convVPS((5*yy[i]+yy[i+1])/6) - py);
!       numout(dx = (integer)convPS((xx[i]+xx[i+1])/2) - px);
!       numout(dy = (integer)convVPS((yy[i]+yy[i+1])/2) - py);
!       px += dx;
!       py += dy;
        cmdout(RCURVETO);
      }
  
diff -cr dvipsk.orig/dvips.c dvipsk/dvips.c
*** dvipsk.orig/dvips.c	Tue May 28 06:08:07 2002
--- dvipsk/dvips.c	Mon Jul 22 15:49:07 2002
***************
*** 50,55 ****
--- 50,56 ----
  #ifdef VMS
      static char ofnme[252],infnme[252],pap[40],thh[20];
  #endif
+ Boolean SJIS ;            /* KANJI code */
  fontdesctype *fonthead ;      /* list of all fonts mentioned so far */
  fontdesctype *curfnt ;        /* the currently selected font */
  sectiontype *sections ;       /* sections to process document in */
***************
*** 185,191 ****
--- 186,195 ----
  int nextfonthd;                 /* next unused fonthd[] index */
  char xdig[256];                 /* table for reading hexadecimal digits */
  char banner[] = BANNER ;        /* our startup message */
+ #ifndef Omega
  char banner2[] = BANNER2 ;      /* our second startup message */
+ #endif
+ char weburl[] = WEBURL;         /* DVIPSK WEB page */
  Boolean noenv = 0 ;             /* ignore PRINTER envir variable? */
  Boolean dopprescan = 0 ;        /* do we do a scan before the prescan? */
  extern int dontmakefont ;
***************
*** 288,293 ****
--- 292,298 ----
  "x # Override dvi magnification     X # Horizontal resolution           ",
  "y # Multiply by dvi magnification  Y # Vertical resolution             ",  
  "z*  Hyper PS                       Z*  Compress bitmap fonts           ",
+ "SJIS* Shift-JIS encoding",
  /* "-   Interactive query of options", */
  "    # = number   f = file   s = string  * = suffix, `0' to turn off    ",
  "    c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)           ", 0} ;
***************
*** 443,448 ****
--- 448,454 ----
     for (s="abcdef"; *s!=0; s++)
        xdig[(int)*s] = i++;
     morestrings() ;
+    SJIS = 0 ;
     maxpages = 100000 ;
     numcopies = 1 ;
     iname = fulliname = strings ;
***************
*** 620,631 ****
          exit (0);
        }
        if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) {
!          printf("%s %s\n", banner, banner2) ;
           help(0);
           exit(0);
        }
        if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) {
!          printf("%s %s\n", banner, banner2) ;
           exit(0);
        }
     }
--- 626,645 ----
          exit (0);
        }
        if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) {
! #ifdef Omega
!          printf("%s\n", banner) ;
! #else
!          printf("%s\n%s\n", banner, banner2) ;
! #endif
           help(0);
           exit(0);
        }
        if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) {
! #ifdef Omega
!          printf("%s\n", banner) ;
! #else
!          printf("%s\n%s\n", banner, banner2) ;
! #endif
           exit(0);
        }
     }
***************
*** 724,730 ****
                    else 
                       psmapfile = strdup(PSname) ; /* a cute small memory leak (just as in 'p' option handling in resident.c) */
                 }
!                break ;
  case 'h' : case 'H' :
                 if (*p == 0 && argv[i+1])
                    p = argv[++i] ;
--- 738,744 ----
                    else 
                       psmapfile = strdup(PSname) ; /* a cute small memory leak (just as in 'p' option handling in resident.c) */
                 }
!                break;
  case 'h' : case 'H' :
                 if (*p == 0 && argv[i+1])
                    p = argv[++i] ;
***************
*** 749,758 ****
--- 763,775 ----
                 secure = (*p != '0') ;
                 break ;
  case 'S':
+                if (STREQ (p, "JIS")) SJIS = (*(p + 3) != '0') ;
+                else {
                 if (*p == 0 && argv[i+1])
                    p = argv[++i] ;
                 if (sscanf(p, "%d", &maxsecsize)==0)
                    error("! Bad section size arg (-S).") ;
+                }
                 break ;
  case 'm' :
                 if (STREQ (p, "ode")) {
***************
*** 890,896 ****
                    paperfmt = p ;
                 break ;
  case 'v':
!                 printf ("%s %s\n", banner, banner2);
                  exit (0);
                  break;
  case 'x' : case 'y' :
--- 907,917 ----
                    paperfmt = p ;
                 break ;
  case 'v':
! #ifdef Omega
!                 printf("%s\n", banner) ;
! #else
!                 printf("%s\n%s\n", banner, banner2) ;
! #endif
                  exit (0);
                  break;
  case 'x' : case 'y' :
***************
*** 1068,1074 ****
        }
        papsizes = (struct papsiz *)revlist((void *)papsizes) ;
        if (queryoptions != 0) {            /* get new options */
!          (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
           help(1) ;
           queryargs();
           if (qargc == 1)
--- 1089,1099 ----
        }
        papsizes = (struct papsiz *)revlist((void *)papsizes) ;
        if (queryoptions != 0) {            /* get new options */
! #ifdef Omega
!          (void)fprintf(stderr, "%s\n", banner) ;
! #else
!          (void)fprintf(stderr, "%s\n%s\n", banner, banner2) ;
! #endif
           help(1) ;
           queryargs();
           if (qargc == 1)
***************
*** 1106,1112 ****
     getpsinfo((char *)NULL) ;
     revpslists() ;
     if (!quiet)
!       (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
     if (*iname) {
        dvifile = fopen(iname, READBIN) ;
  /*
--- 1131,1141 ----
     getpsinfo((char *)NULL) ;
     revpslists() ;
     if (!quiet)
! #ifdef Omega
!       (void)fprintf(stderr, "%s\n", banner) ;
! #else
!       (void)fprintf(stderr, "%s\n%s\n", banner, banner2) ;
! #endif
     if (*iname) {
        dvifile = fopen(iname, READBIN) ;
  /*
diff -cr dvipsk.orig/dvips.h dvipsk/dvips.h
*** dvipsk.orig/dvips.h	Tue May 28 06:08:07 2002
--- dvipsk/dvips.h	Mon Jul 22 16:00:19 2002
***************
*** 13,24 ****
  
  #ifdef Omega
  #define BANNER \
! "This is (Omega) odvips(k) 5.90a Copyright 2002 Radical Eye Software"
  #else
  #define BANNER \
! "This is dvips(k) 5.90a Copyright 2002 Radical Eye Software"
  #endif
! #define BANNER2 "(www.radicaleye.com)"
  #ifdef KPATHSEA
  #include "config.h"
  #include "debug.h"
--- 13,26 ----
  
  #ifdef Omega
  #define BANNER \
! "This is (Omega) odvips(k) 5.90a Copyright 2002 Radical Eye Software (www.radicaleye.com)"
  #else
  #define BANNER \
! "This is dvips(k) 5.90a p1.5g Copyright 1996-2002 ASCII Corp.(www-ptex@ascii.co.jp)"
! #define BANNER2 \
! "based on dvips(k) 5.90a Copyright 2002 Radical Eye Software (www.radicaleye.com)"
  #endif
! #define WEBURL "(www.radicaleye.com)"
  #ifdef KPATHSEA
  #include "config.h"
  #include "debug.h"
***************
*** 70,76 ****
  #define RASTERCHUNK (8192)  /* size of chunk of raster */
  #define MINCHUNK (240)      /* minimum size char to get own raster */
  #define STACKSIZE (350)     /* maximum stack size for dvi files */
! #define MAXFRAME (10)       /* maximum depth of virtual font recursion */
  #define MAXFONTHD (100)     /* number of unique names of included fonts */
  #define STDOUTSIZE (75)     /* width of a standard output line */
  /*
--- 72,78 ----
  #define RASTERCHUNK (8192)  /* size of chunk of raster */
  #define MINCHUNK (240)      /* minimum size char to get own raster */
  #define STACKSIZE (350)     /* maximum stack size for dvi files */
! #define MAXFRAME (50)       /* maximum depth of virtual font recursion */
  #define MAXFONTHD (100)     /* number of unique names of included fonts */
  #define STDOUTSIZE (75)     /* width of a standard output line */
  /*
***************
*** 175,181 ****
   *   psfile.  It can be 0, PREVPAGE, THISPAGE, or EXISTS.
   */
  typedef struct tfd {
!    integer checksum, scaledsize, designsize, thinspace ;
     halfword dpi, loadeddpi ;
     halfword alreadyscaled ;
     halfword psname ;
--- 177,183 ----
   *   psfile.  It can be 0, PREVPAGE, THISPAGE, or EXISTS.
   */
  typedef struct tfd {
!    integer checksum, scaledsize, designsize, thinspace , dir;
     halfword dpi, loadeddpi ;
     halfword alreadyscaled ;
     halfword psname ;
***************
*** 195,201 ****
  #ifdef Omega
     chardesctype *chardesc ;
  #else
!    chardesctype chardesc[256] ;
  #endif
  } fontdesctype ;
  
--- 197,203 ----
  #ifdef Omega
     chardesctype *chardesc ;
  #else
!    chardesctype *chardesc ;
  #endif
  } fontdesctype ;
  
diff -cr dvipsk.orig/loadfont.c dvipsk/loadfont.c
*** dvipsk.orig/loadfont.c	Tue May 28 06:08:07 2002
--- dvipsk/loadfont.c	Mon Jul 22 15:37:54 2002
***************
*** 361,366 ****
--- 361,367 ----
        tfmload(curfnt) ;
        return ;
     }
+    curfnt->dir = 0;
  #ifdef DEBUG
     if (dd(D_FONTS))
        (void)fprintf(stderr,"Loading pk font %s at %.1fpt\n",
***************
*** 373,389 ****
--- 374,394 ----
     for(i=pkbyte(); i>0; i--)
        (void)pkbyte() ;
     k = (integer)(alpha * (real)pkquad()) ;
+ /*
     if (k > curfnt->designsize + fsizetol ||
         k < curfnt->designsize - fsizetol) {
        (void)sprintf(errbuf,"Design size mismatch in font %s", curfnt->name) ;
        error(errbuf) ;
     }
+ */
     k = pkquad() ;
+ /*
     if (k && curfnt->checksum)
        if (k!=curfnt->checksum) {
           (void)sprintf(errbuf,"Checksum mismatch in font %s", curfnt->name) ;
           error(errbuf) ;
         }
+ */
     k = pkquad() ; /* assume that hppp is correct in the PK file */
     k = pkquad() ; /* assume that vppp is correct in the PK file */
  /*
diff -cr dvipsk.orig/output.c dvipsk/output.c
*** dvipsk.orig/output.c	Tue May 28 06:08:07 2002
--- dvipsk/output.c	Mon Jul 22 15:38:50 2002
***************
*** 30,35 ****
--- 30,37 ----
   *   These are the external variables used by these routines.
   */
  extern integer hh, vv ;
+ extern integer dir ;
+ extern Boolean SJIS ;
  extern fontdesctype *curfnt ;
  extern FILE *bitfile ;
  extern char *oname ;
***************
*** 63,69 ****
  extern char errbuf[] ;
  extern shalfword linepos ;
  extern struct header_list *ps_fonts_used ;
! extern char banner[], banner2[] ;
  extern int gargc ;
  extern char **gargv ;
  extern struct papsiz *papsizes ;
--- 65,75 ----
  extern char errbuf[] ;
  extern shalfword linepos ;
  extern struct header_list *ps_fonts_used ;
! #ifdef Omega
! extern char banner[], weburl[] ;
! #else
! extern char banner[], banner2[], weburl[] ;
! #endif
  extern int gargc ;
  extern char **gargv ;
  extern struct papsiz *papsizes ;
***************
*** 75,80 ****
--- 81,88 ----
  /*
   *   We need a few statics to take care of things.
   */
+ integer rdir = 0, fdir = 0 ;
+ static Boolean jflag = 0 ;
  static integer rhh, rvv ;
  static int instring ;
  static Boolean lastspecial = 1 ;
***************
*** 641,646 ****
--- 649,655 ----
   *   need room for (, ), and a possible four-byte string \000, for
   *   instance.  If it is too long, we send out the string.
   */
+    jflag = 0;
     if (instring > LINELENGTH-6) {
        stringend() ;
        chrcmd('p') ;
***************
*** 677,688 ****
  }
  
  void
  cmdout P1C(char *, s)
  {
     int l ;
  
     /* hack added by dorab */
!    if (instring) {
          stringend();
          chrcmd('p');
     }
--- 686,719 ----
  }
  
  void
+ jscout(c)   /* string character out */
+         halfword c ;
+ {
+    char s[64];
+ 
+    if (!dir) {
+       numout(hh) ;
+       numout(vv) ;
+    } else {
+       numout(vv) ;
+       numout(-hh) ;
+    }
+    if (SJIS) c = JIStoSJIS(c) ;
+    sprintf(s, "a<%x>p", c) ;
+    cmdout(s);
+    lastspecial = 1 ;
+    instring = 0 ;
+    jflag = 1 ;
+    strbuffer[0] = '\0' ;
+ }
+ 
+ void
  cmdout P1C(char *, s)
  {
     int l ;
  
     /* hack added by dorab */
!    if (instring && !jflag) {
          stringend();
          chrcmd('p');
     }
***************
*** 692,698 ****
        (void)putc('\n', bitfile) ;
        linepos = 0 ;
        lastspecial = 1 ;
!    } else if (! lastspecial) {
        (void)putc(' ', bitfile) ;
        linepos++ ;
     }
--- 723,729 ----
        (void)putc('\n', bitfile) ;
        linepos = 0 ;
        lastspecial = 1 ;
!    } else if (linepos > 0) {
        (void)putc(' ', bitfile) ;
        linepos++ ;
     }
***************
*** 710,716 ****
        (void)putc('\n', bitfile) ;
        linepos = 0 ;
        lastspecial = 1 ;
!    } else if (! lastspecial) {
        (void)putc(' ', bitfile) ;
        linepos++ ;
     }
--- 741,747 ----
        (void)putc('\n', bitfile) ;
        linepos = 0 ;
        lastspecial = 1 ;
!    } else {
        (void)putc(' ', bitfile) ;
        linepos++ ;
     }
***************
*** 779,785 ****
  {
     char buf[6] ;
  
!    if (instring) {
        stringend() ;
        chrcmd('p') ;
     }
--- 810,816 ----
  {
     char buf[6] ;
  
!    if (instring && !jflag) {
        stringend() ;
        chrcmd('p') ;
     }
***************
*** 790,845 ****
  void
  hvpos P1H(void)
  {
!    if (rvv != vv) {
!       if (instring) {
!          stringend() ;
!          numout(hh) ;
!          numout(vv) ;
!          chrcmd('y') ;
!       } else if (rhh != hh) {
!          numout(hh) ;
!          numout(vv) ;
!          chrcmd('a') ;
!       } else { /* hard to get this case, but it's there when you need it! */
!          numout(vv - rvv) ;
!          chrcmd('x') ;
!       }
!       rvv = vv ;
!    } else if (rhh != hh) {
!       if (instring) {
!          stringend() ;
!          if (hh - rhh < 5 && rhh - hh < 5) {
  #ifdef VMCMS /*  should replace 'p' in non-VMCMS line as well */
!             chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ;
  #else
  #ifdef MVSXA /*  should replace 'p' in non-MVSXA line as well */
!             chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ;
  #else
!             chrcmd((char)('p' + hh - rhh)) ;
  #endif
  #endif
!          } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) {
  #ifdef VMCMS /* should replace 'g' in non-VMCMS line as well  */
!             chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ;
  #else
  #ifdef MVSXA /* should replace 'g' in non-MVSXA line as well  */
!             chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ;
  #else
!             chrcmd((char)('g' + hh - rhh - d)) ;
  #endif
  #endif
!             d = hh - rhh ;
           } else {
!             numout(hh - rhh) ;
!             chrcmd('b') ;
!             d = hh - rhh ;
!          }
!       } else {
           numout(hh - rhh) ;
           chrcmd('w') ;
        }
     }
-    rhh = hh ;
  }
  
  /*
--- 821,949 ----
  void
  hvpos P1H(void)
  {
!    if (!dir) {
!       if (rvv != vv || jflag) {
!          if (instring) {
!             stringend() ;
!             numout(hh) ;
!             numout(vv) ;
!             chrcmd('y') ;
!          } else {
!             numout(hh) ;
!             numout(vv) ;
!             chrcmd('a') ;
!          }
!          rvv = vv ;
!       } else if (rhh != hh || jflag) {
!          if (instring) {
!             stringend() ;
!             if (hh - rhh < 5 && rhh - hh < 5) {
  #ifdef VMCMS /*  should replace 'p' in non-VMCMS line as well */
!                chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ;
  #else
  #ifdef MVSXA /*  should replace 'p' in non-MVSXA line as well */
!                chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ;
  #else
!                chrcmd((char)('p' + hh - rhh)) ;
  #endif
  #endif
!             } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) {
  #ifdef VMCMS /* should replace 'g' in non-VMCMS line as well  */
!                chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ;
  #else
  #ifdef MVSXA /* should replace 'g' in non-MVSXA line as well  */
!                chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ;
  #else
!                chrcmd((char)('g' + hh - rhh - d)) ;
! #endif
  #endif
+                d = hh - rhh ;
+             } else {
+ #if 0
+                chrcmd('p') ;
+                numout(hh) ;
+                numout(vv) ;
+                chrcmd('a') ;
+ #else
+ 	      numout(hh - rhh) ;
+ 	      chrcmd('b') ;
+ 	      d = hh - rhh ;
  #endif
!             }
           } else {
! #if 0
!             numout(hh) ;
!             numout(vv) ;
!             chrcmd('a') ;
! #else
           numout(hh - rhh) ;
           chrcmd('w') ;
+ #endif
+          }
+       }
+       rhh = hh ;
+    } else {
+       if (rhh != hh || jflag) {
+          if (instring) {
+             stringend() ;
+             numout(vv) ;
+             numout(-hh) ;
+             chrcmd('y') ;
+          } else {
+             numout(vv) ;
+             numout(-hh) ;
+             chrcmd('a') ;
+          }
+          rhh = hh ;
+       } else if (rvv != vv || jflag) {
+          if (instring) {
+             stringend() ;
+             if (vv - rvv < 5 && rvv - vv < 5) {
+ #ifdef VMCMS /*  should replace 'p' in non-VMCMS line as well */
+                chrcmd(ascii2ebcdic[(char)(112 + vv - rvv)]) ;
+ #else
+ #ifdef MVSXA /*  should replace 'p' in non-MVSXA line as well */
+                chrcmd(ascii2ebcdic[(char)(112 + vv - rvv)]) ;
+ #else
+                chrcmd((char)('p' + vv - rvv)) ;
+ #endif
+ #endif
+             } else if (vv - rvv < d + 5 && rvv - vv < 5 - d) {
+ #ifdef VMCMS /* should replace 'g' in non-VMCMS line as well  */
+                chrcmd(ascii2ebcdic[(char)(103 + vv - rvv - d)]) ;
+ #else
+ #ifdef MVSXA /* should replace 'g' in non-MVSXA line as well  */
+                chrcmd(ascii2ebcdic[(char)(103 + vv - rvv - d)]) ;
+ #else
+                chrcmd((char)('g' + vv - rvv - d)) ;
+ #endif
+ #endif
+                d = vv - rvv ;
+             } else {
+ #if 0
+                chrcmd('p') ;
+                numout(vv) ;
+                numout(-hh) ;
+                chrcmd('a') ;
+ #else
+                numout(vv - rvv) ;
+                chrcmd('b') ;
+                d = vv - rvv ;
+ #endif
+             }
+          } else {
+ #if 0
+             numout(vv) ;
+             numout(-hh) ;
+             chrcmd('a') ;
+ #else
+              numout(vv - rvv) ;
+              chrcmd('w') ;
+ #endif
+          }
        }
+       rvv = vv ;
     }
  }
  
  /*
***************
*** 1199,1204 ****
--- 1303,1311 ----
        if (tryepsf && isepsf == 0)
           error("We tried, but couldn't make it EPSF.") ;
        (void)fprintf(bitfile, "%%%%Creator: %s\n", banner + 8) ;
+ #ifndef Omega
+       (void)fprintf(bitfile, "%%%%%s\n", banner2) ;
+ #endif
        if (*iname)
           (void)fprintf(bitfile, "%%%%Title: %s\n", iname) ;
  #ifdef CREATIONDATE
***************
*** 1238,1244 ****
   *   Here, too, we have to be careful not to exceed the line length
   *   limitation, if possible.
   */
!       (void)fprintf(bitfile, "%%DVIPSWebPage: %s\n", banner2) ;
        (void)fprintf(bitfile, "%%DVIPSCommandLine:") ;
        len = 18 ;
        for (i=0; i<gargc; i++) {
--- 1345,1351 ----
   *   Here, too, we have to be careful not to exceed the line length
   *   limitation, if possible.
   */
!       (void)fprintf(bitfile, "%%DVIPSWebPage: %s\n", weburl) ;
        (void)fprintf(bitfile, "%%DVIPSCommandLine:") ;
        len = 18 ;
        for (i=0; i<gargc; i++) {
***************
*** 1436,1441 ****
--- 1543,1554 ----
        stringend() ;
        chrcmd('p') ;
     }
+ 
+    if (dir)
+       cmdout("-90 rotate") ;
+ 
+    cmdout("dyy") ;
+ 
     cmdout("eop") ;
     cmdout("end") ;
  #ifdef HPS
***************
*** 1454,1461 ****
  void
  drawrule P2C(integer, rw, integer, rh)
  {
!    numout((integer)hh) ;
!    numout((integer)vv) ;
     if (rw == rulex && rh == ruley)
        chrcmd('V') ;
     else {
--- 1567,1581 ----
  void
  drawrule P2C(integer, rw, integer, rh)
  {
!    if (!dir) {
!       numout((integer)hh) ;
!       numout((integer)vv) ;
!    }
!    else {
!       numout((integer)vv) ;
!       numout((integer)-hh) ;
!    }
! 
     if (rw == rulex && rh == ruley)
        chrcmd('V') ;
     else {
***************
*** 1473,1485 ****
  void
  drawchar P2C(chardesctype *, c, int, cc)
  {
!    hvpos() ;
     if (lastfont != curfnt->psname) {
        fontout((int)curfnt->psname) ;
        lastfont = curfnt->psname ;
     }
!    scout((unsigned char)cc) ;
!    rhh = hh + c->pixelwidth ; /* rvv = rv */
  }
  /*
   *   This routine sends out the document fonts comment.
--- 1593,1635 ----
  void
  drawchar P2C(chardesctype *, c, int, cc)
  {
!    if (rdir != dir || fdir != curfnt->dir) {
!       if (curfnt->dir == 9)
!          setdir(dir+2) ;
!       else
!          setdir(dir) ;
!       rdir = dir ;
!       fdir = curfnt->dir ;
!    }
! 
     if (lastfont != curfnt->psname) {
        fontout((int)curfnt->psname) ;
        lastfont = curfnt->psname ;
     }
!    if (cc<256) {
!            if (jflag) {
!               if (!dir){
!                  numout(hh) ;
!                  numout(vv) ;
!               }
!               else {
!                  numout(vv) ;
!                  numout(-hh) ;
!               }
!               chrcmd('a') ;
!               rhh = hh;
!               rvv = vv;
!            }
! 	   else hvpos() ;
! 	   scout((unsigned char)cc) ;
!    }
!    else {
!       jscout(cc);
!    }
!    if (!dir)
!       rhh = hh + c->pixelwidth ; /* rvv = rv */
!    else
!       rvv = vv + c->pixelwidth ; /* rhh = rh */
  }
  /*
   *   This routine sends out the document fonts comment.
***************
*** 1506,1508 ****
--- 1656,1718 ----
     }
     fprintf(bitfile, "\n") ;
  }
+ 
+ int setdir(d)
+ int d ;
+ {
+    if (instring) {
+       stringend() ;
+       chrcmd('p') ;
+    }
+    switch(d) {
+    case 1 :
+       cmdout("dyt") ;
+       break ;
+    case 2 :
+       cmdout("dty") ;
+       break ;
+    case 3 :
+       cmdout("dtt") ;
+       break ;
+    default :
+       cmdout("dyy") ;
+       break ;
+    }
+    linepos += 4;
+ }
+ 
+ int cmddir()
+ {
+    if (dir != rdir) {
+       if (dir)
+          cmdout("90 rotate") ;
+       else
+          cmdout("-90 rotate") ;
+       rdir = dir ;
+    }
+ }
+ 
+ int JIStoSJIS(c)
+ int c;
+ {
+ 	int high, low;
+ 	int nh,nl;
+ 
+ 	high = (c>>8) & 0xff;
+ 	low = c & 0xff;
+ 	nh = ((high-0x21)>>1) + 0x81;
+ 	if (nh>0x9f)
+ 	nh += 0x40;
+ 	if (high & 1) {
+ 		nl = low + 0x1f;
+ 		if (low>0x5f)
+ 		nl++;
+ 	}
+ 	else
+ 		nl = low + 0x7e;
+ 	if (((nh >= 0x81 && nh <= 0x9f) || (nh >= 0xe0 && nh <= 0xfc))
+ 	&& (nl >= 0x40 && nl <= 0xfc && nl != 0x7f))
+ 		return((nh<<8) | nl);
+ 	else
+ 		return(0x813f);
+ }
diff -cr dvipsk.orig/pprescan.c dvipsk/pprescan.c
*** dvipsk.orig/pprescan.c	Sun Nov  1 12:45:08 1998
--- dvipsk/pprescan.c	Mon Jul 22 15:38:03 2002
***************
*** 58,63 ****
--- 58,64 ----
  static void
  pscanpage P1H(void)
  {
+    register halfword i ;
     register shalfword cmd ;
     register chardesctype *cd ;
     register fontmaptype *cfnt = 0 ;
***************
*** 115,123 ****
  	 mychar = cmd ;
    dochar:
  #else
! case 129: case 130: case 131: case 134: case 135: case 136: case 139:
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: case 255: /* unimplemented or illegal commands */
           (void)sprintf(errbuf,
              "! DVI file contains unexpected command (%d)",cmd) ;
           error(errbuf) ;
--- 116,124 ----
  	 mychar = cmd ;
    dochar:
  #else
! case 130: case 131: case 135: case 136: case 139:
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254:  /* unimplemented or illegal commands */
           (void)sprintf(errbuf,
              "! DVI file contains unexpected command (%d)",cmd) ;
           error(errbuf) ;
***************
*** 135,141 ****
  case 144: case 149: case 154: case 158: case 163: case 168:
     /* two-byte commands right2, w2, x2, down2, y2, z2 */
           (void)dvibyte() ;
! case 143: case 148: case 153: case 157: case 162: case 167:
     /* one-byte commands right1, w1, x1, down1, y1, z1 */
           (void)dvibyte() ;
  case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
--- 136,142 ----
  case 144: case 149: case 154: case 158: case 163: case 168:
     /* two-byte commands right2, w2, x2, down2, y2, z2 */
           (void)dvibyte() ;
! case 143: case 148: case 153: case 157: case 162: case 167: case 255:
     /* one-byte commands right1, w1, x1, down1, y1, z1 */
           (void)dvibyte() ;
  case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
***************
*** 153,163 ****
              frp->curf = curfnt ;
              if (++frp == &frames[MAXFRAME] )
                 error("! virtual recursion stack overflow") ;
- #ifdef Omega
-             cd = curfnt->chardesc + mychar;
- #else
              cd = curfnt->chardesc + cmd ;
- #endif
              if (cd->packptr == 0)
      error("! a non-existent virtual char is being used; check vf/tfm files") ;
              curpos = cd->packptr + 2 ;
--- 154,160 ----
***************
*** 168,179 ****
              else
                 ppreselectfont(ffont->desc) ;
           } else if (curfnt->loaded == 3)
- #ifdef Omega
-             curfnt->chardesc[mychar].flags = EXISTS ;
- #else
              curfnt->chardesc[cmd].flags = EXISTS ;
- #endif
           break ;
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
--- 165,198 ----
              else
                 ppreselectfont(ffont->desc) ;
           } else if (curfnt->loaded == 3)
              curfnt->chardesc[cmd].flags = EXISTS ;
           break ;
+ #ifndef Omega
+ case 134: case 129: cmd = twobytes() ; /* set2 commands drops through */
+          if (curfnt==NULL)
+             error("! Bad DVI file: no font selected") ;
+          if (cmd>=256) cmd = ((cmd>>8)-0x21)*94 + (cmd&0xff)-0x21 ;
+          if (curfnt->loaded == 2) { /* scanning a virtual font character */
+             frp->curp = curpos ;
+             frp->curl = curlim ;
+             frp->ff = ffont ;
+             frp->curf = curfnt ;
+             if (++frp == &frames[MAXFRAME] )
+                error("! virtual recursion stack overflow") ;
+             cd = curfnt->chardesc + cmd ;
+             if (cd->packptr == 0)
+     error("! a non-existent virtual char is being used; check vf/tfm files") ;
+             curpos = cd->packptr + 2 ;
+             curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ;
+             ffont = curfnt->localfonts ;
+             if (ffont==NULL)
+                curfnt = NULL ;
+             else
+                ppreselectfont(ffont->desc) ;
+          } else if (curfnt->loaded == 3)
+             curfnt->chardesc[cmd].flags = EXISTS ;
+          break ;
+ #endif
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
diff -cr dvipsk.orig/protos.h dvipsk/protos.h
*** dvipsk.orig/protos.h	Fri Feb  8 05:42:50 2002
--- dvipsk/protos.h	Mon Jul 22 15:38:03 2002
***************
*** 12,18 ****
  /* prototypes for functions from bbox.c */
  extern int nscalewidth P2H(int a, int b);
  extern void bbtfmload P1H(int n);
! extern void bbspecial P3H(int h, int v, int nbytes);
  extern void bbdopage P1H(void);
  extern void findbb P1H(int bop);
  
--- 12,18 ----
  /* prototypes for functions from bbox.c */
  extern int nscalewidth P2H(int a, int b);
  extern void bbtfmload P1H(int n);
! extern void bbspecial P4H(int h, int v, int dir, int nbytes);
  extern void bbdopage P1H(void);
  extern void findbb P1H(int bop);
  
diff -cr dvipsk.orig/psfonts.map dvipsk/psfonts.map
*** dvipsk.orig/psfonts.map	Sun Nov  1 12:45:08 1998
--- dvipsk/psfonts.map	Mon Jul 22 15:38:03 2002
***************
*** 531,536 ****
--- 531,541 ----
  cshb0	 CgShannonBd			<cshb.pfa
  cshx0	 CgShannonExBd			<cshx.pfa
  
+ rml      Ryumin-Light-H
+ rmlv     Ryumin-Light-V
+ gbm      GothicBBB-Medium-H
+ gbmv     GothicBBB-Medium-V
+ 
  % 	
  % Local variables:
  % page-delimiter: "^% \f"
diff -cr dvipsk.orig/resident.c dvipsk/resident.c
*** dvipsk.orig/resident.c	Tue May 28 06:08:07 2002
--- dvipsk/resident.c	Mon Jul 22 15:38:03 2002
***************
*** 35,40 ****
--- 35,41 ----
  #ifdef DEBUG
  extern integer debug_flag;
  #endif  /* DEBUG */
+ extern Boolean SJIS ;
  extern integer pagecopies ;
  extern int overridemag ;
  extern long bytesleft ;
***************
*** 229,234 ****
--- 230,236 ----
  #endif  /* DEBUG */
     curfnt->resfont = p ;
     curfnt->name = p->TeXname ;
+    curfnt->chardesc = (chardesctype *)malloc(sizeof(chardesctype)*256);
     for (i=0; i<256; i++) {
        curfnt->chardesc[i].TFMwidth = 0 ;
        curfnt->chardesc[i].packptr = NULL ;
***************
*** 617,623 ****
  #endif
           break ;
  case 'S' :
!          if (sscanf(was_inline+1, "%s", PSname) != 1) 
  	   bad_config("missing arg to S") ;
           else
  #ifdef KPATHSEA
--- 619,626 ----
  #endif
           break ;
  case 'S' :
!          if (!strncmp(was_inline, "SJIS", 4)) SJIS = (was_inline[4] != '0') ;
!          else if (sscanf(was_inline+1, "%s", PSname) != 1) 
  	   bad_config("missing arg to S") ;
           else
  #ifdef KPATHSEA
diff -cr dvipsk.orig/scanpage.c dvipsk/scanpage.c
*** dvipsk.orig/scanpage.c	Sun Nov  1 12:45:09 1998
--- dvipsk/scanpage.c	Mon Jul 22 15:38:03 2002
***************
*** 126,132 ****
  short
  scanpage P1H(void)
  {
!    register shalfword cmd ;
     register chardesctype *cd ;
     register fontmaptype *cfnt = 0 ;
     integer fnt ;
--- 126,133 ----
  short
  scanpage P1H(void)
  {
!    register integer i ;
!    unsigned short cmd ;
     register chardesctype *cd ;
     register fontmaptype *cfnt = 0 ;
     integer fnt ;
***************
*** 183,191 ****
  case 133: case 128: mychar = dvibyte() ;
           goto dochar ;
  #else
! case 129: case 130: case 131: case 134: case 135: case 136: case 139:
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: case 255: /* unimplemented or illegal commands */
           (void)sprintf(errbuf,
              "! DVI file contains unexpected command (%d)",cmd) ;
           error(errbuf) ;
--- 184,192 ----
  case 133: case 128: mychar = dvibyte() ;
           goto dochar ;
  #else
! case 130: case 131: case 135: case 136: case 139:
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: /* unimplemented or illegal commands */
           (void)sprintf(errbuf,
              "! DVI file contains unexpected command (%d)",cmd) ;
           error(errbuf) ;
***************
*** 203,210 ****
  case 144: case 149: case 154: case 158: case 163: case 168:
     /* two-byte commands right2, w2, x2, down2, y2, z2 */
           (void)dvibyte() ;
! case 143: case 148: case 153: case 157: case 162: case 167:
!    /* one-byte commands right1, w1, x1, down1, y1, z1 */
           (void)dvibyte() ;
  case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
  case 138: case 141: case 142: /* nop, push, pop */
--- 204,211 ----
  case 144: case 149: case 154: case 158: case 163: case 168:
     /* two-byte commands right2, w2, x2, down2, y2, z2 */
           (void)dvibyte() ;
! case 143: case 148: case 153: case 157: case 162: case 167: case 255:
!    /* one-byte commands right1, w1, x1, down1, y1, z1, dir */
           (void)dvibyte() ;
  case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
  case 138: case 141: case 142: /* nop, push, pop */
***************
*** 229,239 ****
              frp->curf = curfnt ;
              if (++frp == &frames[MAXFRAME] )
                 error("! virtual recursion stack overflow") ;
- #ifdef Omega
-             cd = curfnt->chardesc + mychar ;
- #else
              cd = curfnt->chardesc + cmd ;
- #endif
              if (cd->packptr == 0)
   error("! a non-existent virtual character is being used; check vf/tfm files") ;
              curpos = cd->packptr + 2 ;
--- 230,236 ----
***************
*** 245,258 ****
                 goto outofmem ;
           } else {
              pagecost++ ;
- #ifdef Omega
-             if (!prescanchar(curfnt->chardesc + mychar))
- #else
              if (!prescanchar(curfnt->chardesc + cmd))
- #endif
                 goto outofmem ;
           }
           break ;        
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
--- 242,284 ----
                 goto outofmem ;
           } else {
              pagecost++ ;
              if (!prescanchar(curfnt->chardesc + cmd))
                 goto outofmem ;
           }
           break ;        
+ #ifndef Omega
+ case 134: case 129: cmd = twobytes() ; /* set2 commands drops through */
+ /*
+  *   We are going to approximate that each string of consecutive characters
+  *   requires (length of string) bytes of PostScript VM.
+  */
+          if (curfnt==NULL)
+             error("! Bad DVI file: no font selected") ;
+          if (cmd>256) cmd = ((cmd>>8)-0x21)*94 + (cmd&0xff)-0x21;
+          if (curfnt->loaded == 2) { /* scanning a virtual font character */
+             frp->curp = curpos ;
+             frp->curl = curlim ;
+             frp->ff = ffont ;
+             frp->curf = curfnt ;
+             if (++frp == &frames[MAXFRAME] )
+                error("! virtual recursion stack overflow") ;
+             cd = curfnt->chardesc + cmd ;
+             if (cd->packptr == 0)
+  error("! a non-existent virtual character is being used; check vf/tfm files") ;
+             curpos = cd->packptr + 2 ;
+             curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ;
+             ffont = curfnt->localfonts ;
+             if (ffont==NULL)
+                curfnt = NULL ;
+             else if (!preselectfont(ffont->desc))
+                goto outofmem ;
+          } else {
+             pagecost++ ;
+             if (!prescanchar(curfnt->chardesc + cmd))
+                goto outofmem ;
+          }
+          break ;        
+ #endif
  case 171: case 172: case 173: case 174: case 175: case 176: case 177:
  case 178: case 179: case 180: case 181: case 182: case 183: case 184:
  case 185: case 186: case 187: case 188: case 189: case 190: case 191:
diff -cr dvipsk.orig/skippage.c dvipsk/skippage.c
*** dvipsk.orig/skippage.c	Wed Feb 17 16:04:06 1999
--- dvipsk/skippage.c	Mon Jul 22 15:38:03 2002
***************
*** 46,54 ****
  case 247: case 248: case 249: case 250: case 251:
  case 252: case 253: case 254: case 255:
  #else
! case 129: case 130: case 131: case 134: case 135: case 136: case 139: 
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: case 255:
  #endif
           (void)sprintf(errbuf,
  #ifdef SHORTINT
--- 46,54 ----
  case 247: case 248: case 249: case 250: case 251:
  case 252: case 253: case 254: case 255:
  #else
! case 130: case 131: case 135: case 136: case 139: 
  case 247: case 248: case 249: case 250: case 251: case 252: case 253:
! case 254: 
  #endif
           (void)sprintf(errbuf,
  #ifdef SHORTINT
***************
*** 76,83 ****
  case 144: case 149: case 154: case 158: case 163: case 168: case 236:
     cmd = dvibyte() ;
  /* one byte commands */
! case 128: case 133: case 143: case 148: case 153: case 157: case 162:
! case 167: case 235:
     cmd = dvibyte() ;
     break ;
  /* specials */
--- 76,94 ----
  case 144: case 149: case 154: case 158: case 163: case 168: case 236:
     cmd = dvibyte() ;
  /* one byte commands */
! case 128:
! #ifndef Omega
! case 129:
! #endif
! case 133:
! #ifndef Omega
! case 134:
! #endif
! case 143: case 148: case 153:
! case 157: case 162: case 167: case 235:
! #ifndef Omega
! case 255:
! #endif
     cmd = dvibyte() ;
     break ;
  /* specials */
diff -cr dvipsk.orig/tex.lpro dvipsk/tex.lpro
*** dvipsk.orig/tex.lpro	Thu Mar 18 15:29:28 1999
--- dvipsk/tex.lpro	Mon Jul 22 15:38:03 2002
***************
*** 256,262 ****
      65781.76 div /hsize X
    } N
  
! /p {show} N        %  the main character setting routine
  
  /RMat [ 1 0 0 -1 0 0 ] N % things we need for rules
  /BDot 260 string N
--- 256,277 ----
      65781.76 div /hsize X
    } N
  
! /dir 0 def
! /dyy {/dir 0 def
! } B
! /dyt {/dir 1 def
! } B
! /dty {/dir 2 def
! } B
! /dtt {/dir 3 def
! } B
! 
! %/p {show} N        %  the main character setting routine
! /p {dir 2 eq
!    {-90 rotate show 90 rotate}
!    {dir 3 eq {-90 rotate show 90 rotate}
!    {show} ifelse} ifelse
! } N
  
  /RMat [ 1 0 0 -1 0 0 ] N % things we need for rules
  /BDot 260 string N
diff -cr dvipsk.orig/texps.lpro dvipsk/texps.lpro
*** dvipsk.orig/texps.lpro	Tue Nov  3 15:43:11 1998
--- dvipsk/texps.lpro	Mon Jul 22 15:38:03 2002
***************
*** 51,56 ****
--- 51,59 ----
  % The top of stack is now `n [ AT 0 S at*aspect 0 0]';
  % we use this matrix to scale the font later.  We store it in Metrics,
  % which we'll give a different definition to anyway later.
+ %----
+     FontType 0 ne {
+ %----
         /Metrics exch def
  % Now we start the dictionary of length n that will eventually be Metrics:
          dict begin
***************
*** 71,76 ****
--- 74,84 ----
  % Now we put the widths dictionary into the font, after grabbing
  % the current definition of Metrics back.
          Metrics /Metrics currentdict end def
+ %----
+     } {
+         { 1 index type /nametype eq { exit } if exch pop } loop
+     } ifelse
+ %----
  % and duplicate /foo so that it can be used both in definefont
  % and as the name of the macro, which is created first as a 
  % non-executable array so that we can put the new font dictionary 
diff -cr dvipsk.orig/tfmload.c dvipsk/tfmload.c
*** dvipsk.orig/tfmload.c	Tue May 28 06:08:12 2002
--- dvipsk/tfmload.c	Mon Jul 22 15:49:07 2002
***************
*** 102,111 ****
--- 102,113 ----
     register shalfword i ;
     register integer li ;
     integer scaledsize ;
+    shalfword id, nt, lf ;
     shalfword nw, hd ;
     shalfword bc, ec ;
     integer scaled[256] ;
     halfword chardat[256] ;
+    halfword *index, *chartype ;
     int charcount = 0 ;
  
     tfmopen(curfnt) ;
***************
*** 113,119 ****
   *   Next, we read the font data from the tfm file, and store it in
   *   our own arrays.
   */
!    li = tfm16() ; hd = tfm16() ;
     bc = tfm16() ; ec = tfm16() ;
     nw = tfm16() ;
     li = tfm32() ; li = tfm32() ; li = tfm32() ; li = tfm16() ;
--- 115,136 ----
   *   Next, we read the font data from the tfm file, and store it in
   *   our own arrays.
   */
!    id = tfm16() ;
!    if (id == 9 || id == 11) {
!       if (id == 9) curfnt->dir = id ;
!       else curfnt->dir = 0 ;
!       nt = tfm16() ; lf = tfm16() ;
!       curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, sizeof(chardesctype)*(94*120)) ;
!       for (i=256; i<94*120; i++) {
!          curfnt->chardesc[i].TFMwidth = 0 ;
!          curfnt->chardesc[i].packptr = NULL ;
!          curfnt->chardesc[i].pixelwidth = 0 ;
!          curfnt->chardesc[i].flags = 0 ;
!       }
!    }
!    else {curfnt->dir = 0 ;
!    }
!    hd = tfm16() ;
     bc = tfm16() ; ec = tfm16() ;
     nw = tfm16() ;
     li = tfm32() ; li = tfm32() ; li = tfm32() ; li = tfm16() ;
***************
*** 122,132 ****
     li = (integer)(alpha * (real)tfm32()) ;
     if (li > curfnt->designsize + fsizetol ||
         li < curfnt->designsize - fsizetol) {
!       (void)sprintf(errbuf,"Design size mismatch in %s", name) ;
        error(errbuf) ;
     }
     for (i=2; i<hd; i++)
        li = tfm32() ;
     for (i=0; i<256; i++)
        chardat[i] = 256 ;
     for (i=bc; i<=ec; i++) {
--- 139,160 ----
     li = (integer)(alpha * (real)tfm32()) ;
     if (li > curfnt->designsize + fsizetol ||
         li < curfnt->designsize - fsizetol) {
!       (void)sprintf(errbuf,"Design size mismatch in %s", curfnt->name) ;
        error(errbuf) ;
     }
     for (i=2; i<hd; i++)
        li = tfm32() ;
+    if (id == 9 || id == 11) {
+       index = (halfword *)malloc(nt * sizeof(halfword)) ;
+       chartype = (halfword *)malloc(nt * sizeof(halfword)) ;
+       li = tfm16() ;
+       li = tfm16() ;
+       for (i=1; i<nt; i++) {
+          li = tfm16() ;
+          index[i] = ((li>>8)-0x21)*94 + (li&0xff)-0x21 ;
+          chartype[i] = tfm16() ;
+       }
+    }
     for (i=0; i<256; i++)
        chardat[i] = 256 ;
     for (i=bc; i<=ec; i++) {
***************
*** 140,148 ****
     for (i=0; i<nw; i++)
        scaled[i] = scalewidth(tfm32(), scaledsize) ;
     (void)fclose(tfmfile) ;
!    for (i=0; i<256; i++)
!       if (chardat[i]!= 256) {
!          li = scaled[chardat[i]] ;
           curfnt->chardesc[i].TFMwidth = li ;
           if (li >= 0)
              curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)) ;
--- 168,176 ----
     for (i=0; i<nw; i++)
        scaled[i] = scalewidth(tfm32(), scaledsize) ;
     (void)fclose(tfmfile) ;
!    if (id == 9 || id == 11) {
!       for (i=0; i<94*120; i++) {
!          li = scaled[chardat[0]] ;
           curfnt->chardesc[i].TFMwidth = li ;
           if (li >= 0)
              curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)) ;
***************
*** 151,156 ****
--- 179,207 ----
           curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0) ;
           curfnt->chardesc[i].flags2 = EXISTS ;
        }
+       for (i=1; i<nt; i++) {
+          li = scaled[chardat[chartype[i]]] ;
+          curfnt->chardesc[index[i]].TFMwidth = li ;
+          if (li >= 0)
+             curfnt->chardesc[index[i]].pixelwidth = ((integer)(conv*li+0.5)) ;
+          else
+             curfnt->chardesc[index[i]].pixelwidth = -((integer)(conv*-li+0.5)) ;
+          curfnt->chardesc[index[i]].flags = (curfnt->resfont ? EXISTS : 0) ;
+          curfnt->chardesc[index[i]].flags2 = EXISTS ;
+       }
+    }
+    else
+      for (i=0; i<256; i++)
+          if (chardat[i]!= 256) {
+             li = scaled[chardat[i]] ;
+             curfnt->chardesc[i].TFMwidth = li ;
+             if (li >= 0)
+                curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)) ;
+             else
+                curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)) ;
+             curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0) ;
+             curfnt->chardesc[i].flags2 = EXISTS ;
+          }
     curfnt->loaded = 1 ;
     return charcount ;
  }
diff -cr dvipsk.orig/virtualfont.c dvipsk/virtualfont.c
*** dvipsk.orig/virtualfont.c	Tue May 28 06:08:12 2002
--- dvipsk/virtualfont.c	Mon Jul 22 15:38:03 2002
***************
*** 172,178 ****
  #ifdef Omega
     register integer cc ;
  #else
!    register shalfword cc ;
  #endif
     register chardesctype *cd ;
     integer scaledsize = curfnt->scaledsize ;
--- 172,178 ----
  #ifdef Omega
     register integer cc ;
  #else
!    unsigned short cc ;
  #endif
     register chardesctype *cd ;
     integer scaledsize = curfnt->scaledsize ;
***************
*** 189,194 ****
--- 189,195 ----
     if (!kindfont)
        return (0) ;
  #else
+    curfnt->chardesc = (chardesctype *)malloc(sizeof(chardesctype)*256) ;
     if (!vfopen(curfnt))
        return (0) ;
  #endif
***************
*** 226,242 ****
     for(i=vfbyte(); i>0; i--)
        (void)vfbyte() ;
     k = vfquad() ;
     check_checksum (k, curfnt->checksum, curfnt->name);
     k = (integer)(alpha * (real)vfquad()) ;
     if (k > curfnt->designsize + 2 || k < curfnt->designsize - 2) {
        (void)sprintf(errbuf,"Design size mismatch in font %s", name) ;
        error(errbuf) ;
     }
  /*
   * Now we look for font definitions.
   */
     fm = NULL ;
!    while ((cmd=vfbyte())>=243) {
        if (cmd>246)
           badvf("unexpected command in preamble") ;
        newf = vfontdef(scaledsize, cmd-242) ;
--- 227,247 ----
     for(i=vfbyte(); i>0; i--)
        (void)vfbyte() ;
     k = vfquad() ;
+ /*  
     check_checksum (k, curfnt->checksum, curfnt->name);
+ */
     k = (integer)(alpha * (real)vfquad()) ;
+ /*
     if (k > curfnt->designsize + 2 || k < curfnt->designsize - 2) {
        (void)sprintf(errbuf,"Design size mismatch in font %s", name) ;
        error(errbuf) ;
     }
+ */
  /*
   * Now we look for font definitions.
   */
     fm = NULL ;
!    for (i=0; (cmd=vfbyte())>=243; i++) {
        if (cmd>246)
           badvf("unexpected command in preamble") ;
        newf = vfontdef(scaledsize, cmd-242) ;
***************
*** 258,264 ****
  #ifdef Omega
           if (cc<0 || cc>65535) badvf("character code out of range") ;
  #else
!          if (cc<0 || cc>255) badvf("character code out of range") ;
  #endif
           cd = curfnt->chardesc + cc ;
           cd->TFMwidth = scalewidth(vfquad(), scaledsize) ;
--- 263,278 ----
  #ifdef Omega
           if (cc<0 || cc>65535) badvf("character code out of range") ;
  #else
!          if (cc>=256) cc = ((cc>>8)-0x21)*94 + (cc&0xff)-0x21;
!          if (cc==256) {
!             curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, sizeof(chardesctype)*(94*120)) ;
!             for (i=256; i<94*120; i++) {
!                curfnt->chardesc[i].TFMwidth = 0 ;
!                curfnt->chardesc[i].packptr = NULL ;
!                curfnt->chardesc[i].pixelwidth = 0 ;
!                curfnt->chardesc[i].flags = 0 ;
!             }
!          }
  #endif
           cd = curfnt->chardesc + cc ;
           cd->TFMwidth = scalewidth(vfquad(), scaledsize) ;
***************
*** 271,280 ****
  #ifdef Omega
        maxcc = (maxcc<cc) ? cc : maxcc;
  #endif
!       if (cd->TFMwidth >= 0)
!          cd->pixelwidth = ((integer)(conv*cd->TFMwidth+0.5)) ;
!       else
           cd->pixelwidth = -((integer)(conv*-cd->TFMwidth+0.5)) ;
        cd->flags = EXISTS ;
        cd->flags2 = EXISTS ;
        if (bytesleft < length) {
--- 285,296 ----
  #ifdef Omega
        maxcc = (maxcc<cc) ? cc : maxcc;
  #endif
!       if (cd->TFMwidth >= 0) {
!          cd->pixelwidth = ((integer)(conv*(cd->TFMwidth)+0.5)) ;
!       }
!       else {
           cd->pixelwidth = -((integer)(conv*-cd->TFMwidth+0.5)) ;
+        }
        cd->flags = EXISTS ;
        cd->flags2 = EXISTS ;
        if (bytesleft < length) {
diff -cr dvipsk.orig/writet1.c dvipsk/writet1.c
*** dvipsk.orig/writet1.c	Tue Feb 12 08:36:33 2002
--- dvipsk/writet1.c	Mon Jul 22 15:49:07 2002
***************
*** 143,149 ****
  static int extra_glyphs_max;
  */
  
! #define T1_BUF_SIZE   8192
  #define ENC_BUF_SIZE  1024
  
  #define ENC_STANDARD  0
--- 143,149 ----
  static int extra_glyphs_max;
  */
  
! #define T1_BUF_SIZE   32768
  #define ENC_BUF_SIZE  1024
  
  #define ENC_STANDARD  0
