From noro@iias.flab.fujitsu.co.jp Tue Sep 22 00:52:47 1992
Path: akiu!wnoc-snd-ss2!sh.wide!fgw!fdm!flab!iias!numazu!amulet!noro
From: noro@iias.flab.fujitsu.co.jp (Masayuki Noro)
Newsgroups: fj.sources
Subject: xdvi for ASCII-jTeX (pl16)
Message-ID: <NORO.92Sep21190929@otemoyan.iias.flab.fujitsu.co.jp>
Date: 21 Sep 1992 19:09:29 JST
Sender: news@iias.flab.fujitsu.co.jp
Distribution: fj
Organization: IIAS-SIS, Fujitsu Laboratories Ltd., JAPAN.
Lines: 851


$BIY;NDL9q:]8&$NLnO$$G$9!#(Jxdvi pl16 $BMQ$N!"(JASCII-jTeX $BBP1~(J patch $B$G$9!#(J


$BF0:n4D6-(J

1. NTT-jTeX $BMQ$N(J DNP font $B$^$?$O!"(Jwatanabe font ($B$r(J DNP font $B$H$7$F(J
   symbolic link $B$7$?$b$N(J) $B$,$"$k$3$H!#(J

2. X11R4 $B$^$?$O(J X11R5 $B$,F0$$$F$$$k$3$H!#(J


$BDI2C5!G=(J/$BJQ99E@(J

1. ASCII-jTeX $B$,(J preview $B$G$-$k!#(J($B$b$A$m$s(J NTT-jTeX $B$b(J)

2. default $B$N(J shrink factor $B$r(J 4 $B$K$7$F$"$k!#(J

3. key binding $B$r(J vi $BIw$K$7$F$"$k!#$3$N$?$a(J original $B$N(J 'k' $B$,(J 'K'
   $B$K$J$C$F$$$k!#(J

4. NeXT $BMQ(J 2bit depth display $BMQ$N(J Xserver (mouse-X $B$J$I(J) $B$G$bF0:n$9$k!#(J


pl14 $B$+$i$NJQ99E@(J ($B%*%j%8%J%k$N(J)

1. $BOI:d$5$s(J@NTT $B$K$h$k(J fix$B!"$*$h$S(J Sony NEWS $B$N(J 4bit depth display $B$J$I(J
   $B$G(J SEGV $B$r5/$3$7$F$$$?(J bug $B$N(J fix $B$b!"%*%j%8%J%k$N(J pl16 $B$K4^$^$l$F(J
   $B$$$^$7$?!#(J

2. $B;d$,$$$$$+$2$s$KF~$l$F$*$$$?!"Gr9u0J30$N(J fg$B!"(Jbg $B$KBP$9$kCf4V?'$rMQ(J
   $B$$$?(J greyscale anti-aliasing $B$,(J GXor $B$rMQ$$$F@5<0$K%5%]!<%H$5$l$^$7(J
   $B$?!#$3$l$KH<$$!"(J-base <number> $B%*%W%7%g%s$OL5$/$J$j!"Be$o$j$K!"(J
   -gamma <number> $B$r$*;H$$2<$5$$!#(J(manual $BEy$r;2>H$N$3$H(J)

3. $B$J$$(J PK font $B$r(J MakeTeXPK $B$r;H$C$F<+F0@8@.$7$^$9(J(-DMAKEPK)$B!#(J $B$?$@$7!"(J
   DNP font $B$O(J mf $B%U%!%$%k$r;}$?$J$$$N$G!"(Jdmj$B!"(Jdgj $B$G;O$^$k(J font $B$O(J
   mf $B$r5/F0$7$J$$$h$&$K$7$F$"$j$^$9!#(J


$BCm0U(J

1. TEXXET$B!"=D=q$-$K$OBP1~$7$F$$$^$;$s!#(J

2. vf $B$O$h$/CN$i$J$$$N$G!"%F%9%H$7$F$$$^$;$s!#(J

3. depth $B$,(J 2 $B$N(J display $B$O(J NeXT $B$@$H>!<j$K;W$$$3$_$^$9!#(J


patch $B$O!"(Jxdvi-pl16 $B$N(J dir $B$G!"(Jpatch -p1 $B$7$F2<$5$$!#$"$H$O!"(JImakefile
$B$N(J DEFAULT_FONT_PATH $B$J$I$rE,Ev$K=$@5$7$F(J make $B$7$F2<$5$$!#(J-DGREY$B!"(J
-DMAKEPK $B$OF~$l$F$"$j$^$9!#(J

$B2?$+$*$+$7$$F0$-$r$7$?$i$<$R$*CN$i$;2<$5$$!#(J

                                    noro@iias.flab.fujitsu.co.jp

------------------------------------------------------------------
diff -c -r xdvi-16/Imakefile jxdvi-16/Imakefile
*** xdvi-16/Imakefile	Sat Feb  1 12:34:40 1992
--- jxdvi-16/Imakefile	Mon Sep 21 12:05:04 1992
***************
*** 1,7 ****
! DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_VF_PATH=
! DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFS=-DUSE_PK -DUSE_GF -DUSE_PXL -DMSBITFIRST -DBMSHORT -DBUTTONS
  
  DEPLIBS=XawClientDepLibs
  LOCAL_LIBRARIES=XawClientLibs
--- 1,7 ----
! DEFAULT_FONT_PATH=.:/usr/share/lib/tex/pk/pk300:/usr/share/lib/tex/pk/jpk300
  DEFAULT_VF_PATH=
! DEFAULT_FONT_SIZES=240:300:328.6:360:432:518.4:622:746.4:895.8:1075
! DEFS=-DUSE_PK -DUSE_GF -DUSE_PXL -DMSBITFIRST -DBMSHORT -DBUTTONS -DGREY -DMAKEPK
  
  DEPLIBS=XawClientDepLibs
  LOCAL_LIBRARIES=XawClientLibs
diff -c -r xdvi-16/dvi.h jxdvi-16/dvi.h
*** xdvi-16/dvi.h	Sat Mar 28 05:27:15 1992
--- jxdvi-16/dvi.h	Mon Sep 21 11:49:19 1992
***************
*** 4,11 ****
--- 4,13 ----
  
  #define	SETCHAR0	0
  #define	SET1		128
+ #define	SET2		129
  #define	SETRULE		132
  #define	PUT1		133
+ #define	PUT2		134
  #define	PUTRULE		137
  #define	NOP		138
  #define	BOP		139
diff -c -r xdvi-16/dvi_draw.c jxdvi-16/dvi_draw.c
*** xdvi-16/dvi_draw.c	Tue Aug 25 10:44:34 1992
--- jxdvi-16/dvi_draw.c	Mon Sep 21 14:13:11 1992
***************
*** 254,260 ****
  }
  
  static	_Xconst	char	*dvi_table1[] = {
! 	"SET1", NULL, NULL, NULL, "SETRULE", "PUT1", NULL, NULL,
  	NULL, "PUTRULE", "NOP", "BOP", "EOP", "PUSH", "POP", "RIGHT1",
  	"RIGHT2", "RIGHT3", "RIGHT4", "W0", "W1", "W2", "W3", "W4",
  	"X0", "X1", "X2", "X3", "X4", "DOWN1", "DOWN2", "DOWN3",
--- 254,260 ----
  }
  
  static	_Xconst	char	*dvi_table1[] = {
! 	"SET1", "SET2", NULL, NULL, "SETRULE", "PUT1", "PUT2", NULL,
  	NULL, "PUTRULE", "NOP", "BOP", "EOP", "PUSH", "POP", "RIGHT1",
  	"RIGHT2", "RIGHT3", "RIGHT4", "W0", "W1", "W2", "W3", "W4",
  	"X0", "X1", "X2", "X3", "X4", "DOWN1", "DOWN2", "DOWN3",
***************
*** 417,422 ****
--- 417,527 ----
  
  	g->y2 = g->y / shrink_factor;
  }
+ 
+ static	void
+ shrink_glyph_next(g)
+ 	register struct glyph *g;
+ {
+ 	int	rows_left, rows, init_cols, cols_left;
+ 	register int	cols;
+ 	int	x, y;
+ 	long	thesample;
+ 	BMUNIT	*old_ptr;
+ 
+ 	/* These machinations ensure that the character is shrunk according to
+ 	   its hot point, rather than its upper left-hand corner. */
+ 	g->x2 = g->x / shrink_factor;
+ 	init_cols = g->x - g->x2 * shrink_factor;
+ 	if (init_cols <= 0) init_cols += shrink_factor;
+ 	else ++g->x2;
+ 	g->bitmap2.w = g->x2 + ROUNDUP(g->bitmap.w - g->x, shrink_factor);
+ 	/* include row zero with the positively numbered rows */
+ 	cols = g->y + 1; /* spare register variable */
+ 	g->y2 = cols / shrink_factor;
+ 	rows = cols - g->y2 * shrink_factor;
+ 	if (rows <= 0) {
+ 	    rows += shrink_factor;
+ 	    --g->y2;
+ 	}
+ 	g->bitmap2.h = g->y2 + ROUNDUP(g->bitmap.h - cols, shrink_factor) + 1;
+ 
+ 	g->image2 = XCreateImage(DISP, DefaultVisualOfScreen(SCRN),
+ 				 DefaultDepthOfScreen(SCRN),
+ 				 ZPixmap, 0, (char *) NULL,
+ 				 g->bitmap2.w, g->bitmap2.h,
+ 				 BITS_PER_BMUNIT, 0);
+ 	g->pixmap2 = g->image2->data = xmalloc((unsigned)
+ 			g->image2->bytes_per_line * g->bitmap2.h,
+ 			"character pixmap");
+ #ifndef	MSBITFIRST
+ 	g->image2->bitmap_bit_order = LSBFirst;
+ #else
+ 	g->image2->bitmap_bit_order = MSBFirst;
+ #endif
+ 	{
+ 	    short endian = MSBFirst << 8 | LSBFirst;
+ 	    g->image2->byte_order = *((char *) &endian);
+ 	}
+ 	g->image2->bitmap_pad = 32;
+ 
+ 	old_ptr = (BMUNIT *) g->bitmap.bits;
+ 	rows_left = g->bitmap.h;
+ 	y = 0;
+ 	while (rows_left) {
+ 	    x = 0;
+ 	    if (rows > rows_left) rows = rows_left;
+ 	    cols_left = g->bitmap.w;
+ 	    cols = init_cols;
+ 	    while (cols_left) {
+ 		if (cols > cols_left) cols = cols_left;
+ 
+ 		thesample = sample(old_ptr, g->bitmap.bytes_wide,
+ 			g->bitmap.w - cols_left, cols, rows);
+ 		NeXTPutPixel(g->image2, x, y, thesample*100/shrink_factor/shrink_factor);
+ 		cols_left -= cols;
+ 		cols = shrink_factor;
+ 		x++;
+ 	    }
+ 	    *((char **) &old_ptr) += rows * g->bitmap.bytes_wide;
+ 	    rows_left -= rows;
+ 	    rows = shrink_factor;
+ 	    y++;
+ 	}
+ 
+ 	while (y < g->bitmap2.h) {
+ 	    for (x = 0; x < g->bitmap2.w; x++)
+ 		 NeXTPutPixel(g->image2, x, y , 0);
+ 	    y++;
+ 	}
+ 
+ 	g->y2 = g->y / shrink_factor;
+ }
+ 
+ static int nextd[3] = {15,30,50};
+ 
+ set_nextd(str)
+ char *str;
+ {
+ 	int i;
+ 
+ 	if (*str == ':') ++str;
+ 	for ( i = 0; i < 3; i++ ) {
+ 		nextd[i] = atof(str);
+ 		str = index(str, ':');
+ 		if (str == NULL) return;
+ 		++str;
+ 	}
+ }
+ 
+ NeXTPutPixel(image, x, y, percent)
+ XImage *image;
+ int x,y,percent;
+ {
+ 	int pix;
+ 
+ 	pix = percent<nextd[0]?0:percent<nextd[1]?1:percent<nextd[2]?2:3;
+ 	*(image->data+y*image->bytes_per_line+x/4) |= pix<<(2*(3-x%4));
+ }
  #endif	/* GREY */
  
  static	void
***************
*** 498,503 ****
--- 603,610 ----
   *	Find font #n.
   */
  
+ static unsigned int cur_TeXnumber;
+ 
  static	void
  change_font(n)
  	unsigned long n;
***************
*** 512,520 ****
  		    load_font(currinf.fontp);
  		break;
  	    }
! 	if (currinf.fontp == NULL) tell_oops("non-existent font #%d", n);
  	maxchar = currinf.fontp->maxchar;
  	currinf.set_char_p = currinf.fontp->set_char_p;
  }
  
  
--- 619,633 ----
  		    load_font(currinf.fontp);
  		break;
  	    }
! 	if (currinf.fontp == NULL)
! 	    if (n>>24) {
! 		define_kanjifont(n); change_font(n);
! 		return;
! 	    } else
! 		tell_oops("non-existent font #%d", n);
  	maxchar = currinf.fontp->maxchar;
  	currinf.set_char_p = currinf.fontp->set_char_p;
+ 	cur_TeXnumber = n;
  }
  
  
***************
*** 544,551 ****
--- 657,673 ----
  #define	ERRVAL
  #endif
  
+ #ifdef NeXT
  #ifndef	TEXXET
  long
+ set_char(WIDEARG(ubyte, int) ch)
+ #else
+ void
+ set_char(WIDEARG(ubyte, int) cmd, WIDEARG(ubyte, int) ch)
+ #endif
+ #else
+ #ifndef	TEXXET
+ long
  set_char(ch)
  #else
  void
***************
*** 553,558 ****
--- 675,681 ----
  	WIDEARG(ubyte, int)	cmd;
  #endif
  	WIDEARG(ubyte, int)	ch;
+ #endif
  {
  	register struct glyph *g;
  #ifdef	TEXXET
***************
*** 573,578 ****
--- 696,703 ----
  	    open_font_file(currinf.fontp);
  	    Fseek(currinf.fontp->file, g->addr, 0);
  	    (*currinf.fontp->read_char)(currinf.fontp, ch);
+ 	    if ( cur_TeXnumber>>24 )
+ 		adj_kanjiwidth(currinf.fontp, cur_TeXnumber>>24, ch);
  	    if (debug & DBG_BITMAP) print_char((ubyte) ch, g);
  	    currinf.fontp->timestamp = ++current_timestamp;
  	}
***************
*** 588,594 ****
  #ifdef	GREY
  		if (use_grey) {
  		    if (g->pixmap2 == NULL) {
! 			shrink_glyph_grey(g);
  		    }
  		    put_image(g->image2, PXL_H - g->x2, PXL_V - g->y2);
  		} else {
--- 713,722 ----
  #ifdef	GREY
  		if (use_grey) {
  		    if (g->pixmap2 == NULL) {
! 			if ( DefaultDepthOfScreen(SCRN) == 2 )
! 			    shrink_glyph_next(g);
! 			else
! 			    shrink_glyph_grey(g);
  		    }
  		    put_image(g->image2, PXL_H - g->x2, PXL_V - g->y2);
  		} else {
***************
*** 616,623 ****
--- 744,760 ----
  }
  
  
+ #ifdef NeXT
  #ifndef	TEXXET
  long
+ set_vf_char(WIDEARG(ubyte, int) ch)
+ #else
+ void
+ set_vf_char(WIDEARG(ubyte, int) ch, WIDEARG(ubyte, int) cmd)
+ #endif
+ #else
+ #ifndef	TEXXET
+ long
  set_vf_char(ch)
  #else
  void
***************
*** 625,630 ****
--- 762,768 ----
  	WIDEARG(ubyte, int)	cmd;
  #endif
  	WIDEARG(ubyte, int)	ch;
+ #endif
  {
  	register struct macro *m;
  	struct drawinf	oldinfo;
***************
*** 792,797 ****
--- 930,936 ----
  		change_font((unsigned long) (ch - FNTNUM0));
  	    else {
  		long a, b;
+ 		unsigned int subfont,subindex;
  
  		switch (ch) {
  		    case SET1:
***************
*** 802,807 ****
--- 941,955 ----
  #else
  			(*currinf.set_char_p)(ch, xone());
  #endif
+ 			break;
+ 
+ 		    case SET2:
+ 		    case PUT2:
+ 			compute_fc(xnum(2),&subfont,&subindex);
+ 			if ( cur_TeXnumber>>24 != subfont )
+ 			    change_font((cur_TeXnumber&0xffffff)|(subfont<<24));
+ 			a = (*currinf.set_char_p)(subindex);
+ 			if (ch != PUT2) DVI_H += a;
  			break;
  
  		    case SETRULE:
diff -c -r xdvi-16/dvi_init.c jxdvi-16/dvi_init.c
*** xdvi-16/dvi_init.c	Tue Aug 25 10:44:44 1992
--- jxdvi-16/dvi_init.c	Mon Sep 21 12:19:50 1992
***************
*** 127,135 ****
--- 127,139 ----
   */
  
  void
+ #ifdef NeXT
+ realloc_font(struct font *fontp, WIDEARG(ubyte, int) newsize)
+ #else
  realloc_font(fontp, newsize)
  	struct font		*fontp;
  	WIDEARG(ubyte, int)	newsize;
+ #endif
  {
  	struct glyph *glyph;
  
***************
*** 148,156 ****
--- 152,164 ----
   */
  
  void
+ #ifdef NeXT
+ realloc_virtual_font(struct font *fontp, WIDEARG(ubyte, int) newsize)
+ #else
  realloc_virtual_font(fontp, newsize)
  	struct font		*fontp;
  	WIDEARG(ubyte, int)	newsize;
+ #endif
  {
  	struct macro *macro;
  
***************
*** 179,184 ****
--- 187,194 ----
  	int	size_found;
  	int	magic;
  
+ 	if ( kanjifont(fontp->fontname) )
+ 		return;
  	fontp->flags |= FONT_LOADED;
  	fontp->file = font_open(fontp->fontname, &font_found,
  	    (WIDEARG(float, double)) fsize, &size_found, fontp->magstepval,
***************
*** 306,316 ****
--- 316,331 ----
   *      all of the fonts used in the job.
   */
  void
+ #ifdef NeXT
+ define_font(FILE *file, WIDEARG(ubyte, unsigned int) cmnd,
+ 	struct font *vfparent, struct tn **tn_headpp)
+ #else
  define_font(file, cmnd, vfparent, tn_headpp)
  	FILE		*file;
  	WIDEARG(ubyte, unsigned int) cmnd;
  	struct font	*vfparent;	/* vf parent of this font, or NULL */
  	struct tn	**tn_headpp;	/* addr of head of list of TeXnumbers */
+ #endif
  {
  	register struct tn *tnp;
  	struct font *fontp;
***************
*** 386,391 ****
--- 401,601 ----
  	tnp->fontp = fontp;
  }
  
+ /* jsf_names[] and compute_fc : borrowed from jvi2ps1.3j */
+ 
+ char *jsf_names[] = {
+     "", "jsy", "jroma", "jhira", "jkata", 
+     "jgreek", "jrussian", "jkeisen",
+     "jka", "jkb", "jkc", "jkd", "jke", "jkf",
+     "jkg", "jkh", "jki", "jkj", "jkk", "jkl",
+     "jkm", "jkn", "jko", "jkp", "jkq", "jkr",
+     "jks", "jkt", "jku", "jkv", "jkw", "jkx",
+     "jky", "jkz", NULL
+ };
+ 
+ compute_fc(kuten, f, c)
+ register unsigned int kuten;
+ unsigned int *f, *c;
+ {
+     register int n;
+     register unsigned int ku,ten;
+ 
+     ku = kuten>>8; ten = kuten&0xff;
+     ku -= 0x20; ten -= 0x20; *f = 1; *c = 1;
+     if (ku <= 0 || (9 <= ku && ku <= 15) || ku > 84) {
+ 	fprintf(stderr,"invalid ku in jis (%x, %x)", ku+0x20, ten+0x20);
+ 	return;
+     }
+     if (ten < 1 || ten > 94) {
+ 	fprintf(stderr,"invalid ten in jis (%x, %x)", ku+0x20, ten+0x20);
+ 	return;
+     }
+     if (ku <= 8) {
+ 	if (ku == 1) {
+ 	    *f = 1; *c = ten;
+ 	} else if (ku == 2) {
+ 	    *f = 1; *c = ten+100;
+ 	} else if (ku == 3) {
+ 	    *f = 2; *c = ten+32;
+ 	} else {
+ 	    *f = ku-1; *c = ten;
+ 	}
+     } else if (ku <= 47) {	/* Daiich Suijun */
+ 	n = (ku-16)*94+ten-1; *f = (n/256)+8; *c = n%256;
+     } else {			/* Daini Suijun */
+ 	n = (ku-48)*94+ten-1; *f = (n/256)+20; *c = n%256;
+     }
+ }
+ 
+ kanjifont(name)
+ char *name;
+ {
+     return ( !strncmp(name,"min",3) || !strncmp(name,"nmin",4) ||
+ 	!strncmp(name,"goth",4) || !strncmp(name,"ngoth",5) );
+ }
+ 
+ dnpfont(name)
+ char *name;
+ {
+     return ( !strncmp(name,"dmj",3) || !strncmp(name,"dgj",3) );
+ }
+ 
+ void
+ define_kanjifont(n)
+ unsigned int n;
+ {
+ 	unsigned int base,index;
+ 	register struct tn *tnp;
+ 	struct font *fontp,*real_fontp;
+ 	float	fsize;
+ 	int len;
+ 	char *fontname,*name,*head;
+ 	int size;
+ 
+ 	base = n&0xffffff; index = n>>24;
+ 	for (tnp = currinf.tn_head; tnp != NULL; tnp = tnp->next)
+ 		if (tnp->TeXnumber == base) {
+ 			real_fontp = tnp->fontp; break;
+ 		}
+ 	tnp = (struct tn *) xmalloc((unsigned) sizeof(struct tn),
+ 	    "TeXnumber structure");
+ 	tnp->next = tn_head;
+ 	tn_head = tnp;
+ 	currinf.tn_head = tn_head;
+ 	tnp->TeXnumber = n;
+ 	fsize = real_fontp->fsize;
+ 	name = real_fontp->fontname;
+ 	if ( !strncmp(name,"min",3) || !strncmp(name,"nmin",4) )
+ 	    head = "dm";
+ 	else
+ 	    head = "dg";
+ 	for ( ; !isdigit(*name); name++ );
+ 	len = strlen(head) + strlen(jsf_names[index]) + strlen(name);
+ 	fontname = xmalloc((unsigned) len + 1, "font name");
+ 	sprintf(fontname,"%s%s%s",head,jsf_names[index],name);
+ 	if(debug & DBG_PK)
+ 	    Printf("Define kanjifont \"%s\"\n", fontname);
+ 	/*
+ 	 * reuse font if possible
+ 	 */
+ 	for (fontp = font_head;; fontp = fontp->next) {
+ 	    if (fontp == NULL) {		/* if font doesn't exist yet */
+ 		if (list_fonts)
+ 		    Printf("%s at %d dpi\n", fontname, (int) (fsize + 0.5));
+ 		fontp = (struct font *) xmalloc((unsigned) sizeof(struct font),
+ 		    "font structure");
+ 		fontp->dimconv = real_fontp->dimconv;
+ 		fontp->fontname = fontname;
+ 		fontp->fsize = fsize;
+ 		fontp->flags = FONT_IN_USE;
+ 		load_font(fontp);
+ 		fontp->next = font_head;
+ 		font_head = fontp;
+ 		break;
+ 	    }
+ 	    if (strcmp(fontname, fontp->fontname) == 0
+ 		    && size == (int) (5 * fontp->fsize + 0.5)) {
+ 			/* if font already in use */
+ 		reuse_font(fontp);
+ 		free(fontname);
+ 		break;
+ 	    }
+ 	}
+ 	tnp->fontp = fontp;
+ 	if ( index == 1 ) {
+ 	    struct glyph *g;
+ 
+ 	    /* dainippon symbol font; Zenkaku blank is not defined in it. */
+ 	    g = &fontp->glyph[1];
+ 	    g->x = 0; g->y = 0; g->bitmap.w = 1; g->bitmap.h = 1; /* XXX */
+ 	    alloc_bitmap(&g->bitmap);
+ 	    bzero(g->bitmap.bits,g->bitmap.h*g->bitmap.bytes_wide);
+ 	    adj_kanjiwidth(fontp,index,1);
+ 	}
+ }
+ 
+ static double kanji_width[] = {
+     0.962216,0.747434,0.504013,0.353665,
+     0.962216,0.747434,0.504013,0.353665
+ };
+ 
+ static char kanji_sym[] = {
+     0,0,2,2,3,3,7,7,7,6,7,3,3,7,7,6,6,0,0,6,0,6,1,1,0,1,0,0,0,0,7,0,
+     0,0,7,7,0,0,7,3,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,0,0,0,0,
+     0,0,0,0,0,0,0,0,1,1,1,2,2,2,0,0,1,1,1,0,0,0,0,0,6,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ };
+ 
+ static char kanji_hira[] = {
+     0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ };
+ 
+ static char kanji_kata[] = {
+     0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ };
+ 
+ adj_kanjiwidth(fontp,subindex,c)
+ struct font *fontp;
+ unsigned int subindex;
+ ubyte c;
+ {
+     char *tab;
+ 
+     switch (subindex) {
+ 	case 1:
+ 	    tab = kanji_sym; break;
+ 	case 3:
+ 	    tab = kanji_hira; break;
+ 	case 4:
+ 	    tab = kanji_kata; break;
+ 	default:
+ 	    fontp->glyph[c].dvi_adv = fontp->dimconv*(1<<20)*kanji_width[0];
+ 	    return; break;
+     }
+     fontp->glyph[c].dvi_adv = fontp->dimconv*(1<<20)*kanji_width[tab[c]];
+     if ( tab[c] == 1 )
+ 	fontp->glyph[c].x = -fontp->glyph[c].y/5;
+     else if ( tab[c] >= 4 )
+ 	fontp->glyph[c].x = -fontp->glyph[c].y/10;
+ }
  
  /*
   *      process_preamble reads the information in the preamble and stores
diff -c -r xdvi-16/font_open.c jxdvi-16/font_open.c
*** xdvi-16/font_open.c	Sat Jul 25 06:28:54 1992
--- jxdvi-16/font_open.c	Mon Sep 21 12:18:39 1992
***************
*** 688,694 ****
  
  #ifdef	MAKEPK
  	/* Try to create the font. */
! 	if (magstepval != NOBUILD) {
  	    char str[24];
  	    int	dpi	= (mag + 2) / 5;
  
--- 688,694 ----
  
  #ifdef	MAKEPK
  	/* Try to create the font. */
! 	if ((magstepval != NOBUILD) && !dnpfont(font)) {
  	    char str[24];
  	    int	dpi	= (mag + 2) / 5;
  
***************
*** 732,737 ****
--- 732,741 ----
  
  /* ARGSUSED */
  FILE *
+ #ifdef NeXT
+ font_open(_Xconst char *font, char **font_ret, WIDEARG(float, double)mag,
+ 	int *mag_ret, int magstepval, char **name)
+ #else
  font_open(font, font_ret, mag, mag_ret, magstepval, name)
  	_Xconst char	*font;
  	char	**font_ret;
***************
*** 739,744 ****
--- 743,749 ----
  	int	*mag_ret;
  	int	magstepval;
  	char	**name;
+ #endif
  {
  	FILE	*f;
  	int	actual_pt, low_pt, high_pt, trial_pt;
diff -c -r xdvi-16/util.c jxdvi-16/util.c
*** xdvi-16/util.c	Tue Aug 25 10:45:15 1992
--- jxdvi-16/util.c	Mon Sep 21 11:00:05 1992
***************
*** 42,51 ****
  #ifndef	X_NOT_STDC_ENV
  #include <stdlib.h>
  #else
! char	*malloc();
  #endif
  #if	defined(macII) && !defined(__STDC__) /* stdlib.h doesn't define these */
! char	*malloc();
  #endif /* macII */
  
  #if	NeedVarargsPrototypes		/* this is for oops */
--- 42,51 ----
  #ifndef	X_NOT_STDC_ENV
  #include <stdlib.h>
  #else
! char	*calloc();
  #endif
  #if	defined(macII) && !defined(__STDC__) /* stdlib.h doesn't define these */
! char	*calloc();
  #endif /* macII */
  
  #if	NeedVarargsPrototypes		/* this is for oops */
***************
*** 103,109 ****
  	unsigned	size;
  	_Xconst char	*why;
  {
! 	char *mem = malloc(size);
  
  	if (mem == NULL)
  	    oops("! Cannot allocate %u bytes for %s.\n", size, why);
--- 103,109 ----
  	unsigned	size;
  	_Xconst char	*why;
  {
! 	char *mem = calloc(size,1);
  
  	if (mem == NULL)
  	    oops("! Cannot allocate %u bytes for %s.\n", size, why);
diff -c -r xdvi-16/xdvi.c jxdvi-16/xdvi.c
*** xdvi-16/xdvi.c	Sun Sep 13 07:25:42 1992
--- jxdvi-16/xdvi.c	Mon Sep 21 11:49:22 1992
***************
*** 616,621 ****
--- 616,623 ----
  		XCreateGC(DISP, RootWindowOfScreen(SCRN),\
  			GCFunction|GCForeground|GCBackground, &values))
  
+ 	    if ( DefaultDepthOfScreen(SCRN) == 2 )
+ 		RESOURCE(copy) = 0;
  	    foreGC = ruleGC = MakeGC(RESOURCE(copy) ? GXcopy : GXor,
  		RESOURCE(fore_Pixel), RESOURCE(back_Pixel));
  
***************
*** 728,736 ****
--- 730,742 ----
   */
  
  void
+ #ifdef NeXT
+ put_rectangle(int x, int y, int w, int h, WIDEARG(Boolean, int) hl)
+ #else
  put_rectangle(x, y, w, h, hl)
  	int x, y, w, h;
  	WIDEARG(Boolean, int) hl;
+ #endif
  {
  	if (x < max_x && x + w >= min_x && y < max_y && y + h >= min_y) {
  		if (--event_counter == 0) read_events(False);
***************
*** 1487,1493 ****
  	    case 'P':		/* declare current page */
  		pageno_correct = arg0 * number0 - current_page;
  		return;
! 	    case 'k':		/* toggle keep-position flag */
  		RESOURCE(keep_flag) = (arg0 ? number0 : !RESOURCE(keep_flag));
  		return;
  	    case '\f':
--- 1493,1499 ----
  	    case 'P':		/* declare current page */
  		pageno_correct = arg0 * number0 - current_page;
  		return;
! 	    case 'K':		/* toggle keep-position flag */
  		RESOURCE(keep_flag) = (arg0 ? number0 : !RESOURCE(keep_flag));
  		return;
  	    case '\f':
***************
*** 1497,1518 ****
  		home(True);
  		return;
  #ifdef	TOOLKIT
! 	    case 'l':
  		if (!x_bar) goto bad;
  		XtCallCallbacks(x_bar, XtNscrollProc,
  		    (XtPointer) (-2 * (int) clip_w / 3));
  		return;
! 	    case 'r':
  		if (!x_bar) goto bad;
  		XtCallCallbacks(x_bar, XtNscrollProc,
  		    (XtPointer) (2 * (int) clip_w / 3));
  		return;
! 	    case 'u':
  		if (!y_bar) goto bad;
  		XtCallCallbacks(y_bar, XtNscrollProc,
  		    (XtPointer) (-2 * (int) clip_h / 3));
  		return;
! 	    case 'd':
  		if (!y_bar) goto bad;
  		XtCallCallbacks(y_bar, XtNscrollProc,
  		    (XtPointer) (2 * (int) clip_h / 3));
--- 1503,1524 ----
  		home(True);
  		return;
  #ifdef	TOOLKIT
! 	    case 'h':
  		if (!x_bar) goto bad;
  		XtCallCallbacks(x_bar, XtNscrollProc,
  		    (XtPointer) (-2 * (int) clip_w / 3));
  		return;
! 	    case 'l':
  		if (!x_bar) goto bad;
  		XtCallCallbacks(x_bar, XtNscrollProc,
  		    (XtPointer) (2 * (int) clip_w / 3));
  		return;
! 	    case 'k':
  		if (!y_bar) goto bad;
  		XtCallCallbacks(y_bar, XtNscrollProc,
  		    (XtPointer) (-2 * (int) clip_h / 3));
  		return;
! 	    case 'j':
  		if (!y_bar) goto bad;
  		XtCallCallbacks(y_bar, XtNscrollProc,
  		    (XtPointer) (2 * (int) clip_h / 3));
***************
*** 2175,2181 ****
  {"debugLevel", "DebugLevel", XtRString, sizeof(char *),
    offset(debug_arg), XtRString, (caddr_t) NULL},
  {"shrinkFactor", "ShrinkFactor", XtRInt, sizeof(int),
!   offset(_shrink_factor), XtRString, "3"},
  {"densityPercent", "DensityPercent", XtRInt, sizeof(int),
    offset(density), XtRString, "40"},
  #ifdef	GREY
--- 2181,2187 ----
  {"debugLevel", "DebugLevel", XtRString, sizeof(char *),
    offset(debug_arg), XtRString, (caddr_t) NULL},
  {"shrinkFactor", "ShrinkFactor", XtRInt, sizeof(int),
!   offset(_shrink_factor), XtRString, "4"},
  {"densityPercent", "DensityPercent", XtRInt, sizeof(int),
    offset(density), XtRString, "40"},
  #ifdef	GREY

