*** ./fig2dev/dev/psfonts.h.orig	Fri Mar  3 02:57:09 1995
--- ./fig2dev/dev/psfonts.h	Fri Aug  9 10:16:38 1996
***************
*** 33,38 ****
--- 33,49 ----
  			"Courier"			/* typewriter */
  		};
  
+ #ifdef KANJI
+ static char           *pskanjifontnames[] = {
+                       "Ryumin-Light-H", "Ryumin-Light-H", /* default */
+                       "Ryumin-Light-H",                   /* roman */
+                       "GothicBBB-Medium-H",               /* bold */
+                       "Ryumin-Light-H",                   /* italic */
+                       "Ryumin-Light-H",                   /* sans serif */
+                       "Ryumin-Light-H",                   /* typewriter */
+               };
+ #endif
+ 
  extern int v2_flag, v21_flag, v30_flag;
  
  #define PS_FONTNAMES(T)	\
***************
*** 41,46 ****
--- 52,69 ----
  
  #define PSFONT(T) \
   ((T->font) <= MAXFONT(T) ? PS_FONTNAMES(T)[T->font+1] : PS_FONTNAMES(T)[0])
+ 
+ #ifdef KANJI
+ 
+ extern int    PSfontmap[];
+ 
+ #define PSKANJIFONT(T) \
+ ((T->font) <= MAXFONT(T) ? \
+  (((v2_flag && !v21_flag) || psfont_text(T)) ? \
+   pskanjifontnames[PSfontmap[T->font+1]] : pskanjifontnames[T->font+1]) \
+  : pskanjifontnames[0])
+ 
+ #endif
  
  #define PSFONTMAG(T)  (((T->size) <= ULIMIT_FONT_SIZE ? \
  				     T->size :  ULIMIT_FONT_SIZE) \
*** ./fig2dev/dev/genps.c.orig	Wed Aug 16 07:18:40 1995
--- ./fig2dev/dev/genps.c	Tue Aug 13 11:34:37 1996
***************
*** 38,43 ****
--- 38,45 ----
  
  */
  
+ #define	KANJI
+ 
  #include <sys/param.h>
  #if defined(hpux) || defined(SYSV) || defined(BSD4_3) || defined(SVR4)
  #include <sys/types.h>
***************
*** 119,125 ****
--- 121,132 ----
  int		pages;
  int		no_obj = 0;
  int		multi_page = FALSE;
+ #ifdef KANJI
+ int		use_kanji = 1;
+ int		kanji_encoding = 0;
+ #endif
  
+ 
  /* arrowhead arrays */
  Point		bpoints[5], fpoints[5];
  int		nbpoints, nfpoints;
***************
*** 137,142 ****
--- 144,152 ----
  static		encode_all_fonts();
  static		ellipse_exist();
  static		normal_spline_exist();
+ #ifdef KANJI
+ static		encode_kanji_fonts();
+ #endif
  
  #define SHADEVAL(F)	1.0*(F)/(NUMSHADES-1)
  #define TINTVAL(F)	1.0*(F-NUMSHADES+1)/NUMTINTS
***************
*** 290,295 ****
--- 300,311 ----
  		(void) strcpy (pagesize, optarg);
  		break;
  
+ #ifdef KANJI
+ 	case 'i':
+ 		use_kanji = 0;
+ 		break;
+ #endif
+ 
  	default:
  		put_msg(Err_badarg, opt, "ps");
  		exit(1);
***************
*** 438,445 ****
--- 454,473 ----
  	}
  	fprintf(tfp, "\n%s", BEGIN_PROLOG2);
  	if (iso_text_exist(objects)) {
+ #ifdef KANJI
+ 	   if (!use_kanji) {
+ 	   	fprintf(tfp, "%s%s%s", SPECIAL_CHAR_1,SPECIAL_CHAR_2,SPECIAL_CHAR_3);
+ 		encode_all_fonts(objects);
+ 	   } else {
+ 		fprintf(tfp, "%s", KANJI_PROLOG);
+ 		encode_kanji_fonts(objects);
+ 		fputs("%%\n", tfp);
+ 		kanji_encoding = 1;
+ 	   }
+ #else
  	   fprintf(tfp, "%s%s%s", SPECIAL_CHAR_1,SPECIAL_CHAR_2,SPECIAL_CHAR_3);
  	   encode_all_fonts(objects);
+ #endif
  	}
  	if (ellipse_exist(objects))
  		fprintf(tfp, "%s\n", ELLIPSE_PS);
***************
*** 1340,1345 ****
--- 1368,1380 ----
  #define	TEXT_PS		"\
  /%s%s ff %.2f scf sf\n\
  "
+ 
+ #ifdef KANJI
+ #define	KANJI_TEXT_PS	"\
+ /%s-and-%s ff %.2f scf sf\n\
+ "
+ #endif
+ 
  void
  genps_text(t)
  F_text	*t;
***************
*** 1348,1357 ****
--- 1383,1407 ----
  
  	if (multi_page)
  	   fprintf(tfp, "/o%d {", no_obj++);
+ #ifdef KANJI
+ 	   if (!use_kanji) {
+ 		if (PSisomap[t->font+1] == TRUE)
+ 		   fprintf(tfp, TEXT_PS, PSFONT(t), "-iso", PSFONTMAG(t));
+ 		else
+ 		   fprintf(tfp, TEXT_PS, PSFONT(t), "", PSFONTMAG(t));
+ 	   } else {
+ 		if (kanji_encoding)
+ 		   fprintf(tfp, KANJI_TEXT_PS, PSFONT(t), PSKANJIFONT(t),
+ 			PSFONTMAG(t));
+ 		else
+ 		   fprintf(tfp, TEXT_PS, PSFONT(t), "", PSFONTMAG(t));
+ 	   }
+ #else
  	if (PSisomap[t->font+1] == TRUE)
  	   fprintf(tfp, TEXT_PS, PSFONT(t), "-iso", PSFONTMAG(t));
  	else
  	   fprintf(tfp, TEXT_PS, PSFONT(t), "", PSFONTMAG(t));
+ #endif
  
  	fprintf(tfp, "%d %d m\ngs ", t->base_x,  t->base_y);
  	if (coord_system == 2)
***************
*** 1361,1366 ****
--- 1411,1448 ----
  	   fprintf(tfp, " %.1f rot ", t->angle*180/M_PI);
  	/* this loop escapes characters '(', ')', and '\' */
  	fputc('(', tfp);
+ #ifdef KANJI
+ 	if (!use_kanji) {
+ 	    for(cp = (unsigned char *)t->cstring; *cp; cp++) {
+ 		if (strchr("()\\", *cp)) fputc('\\', tfp);
+ 		if (*cp>=0x80)
+ 		    fprintf(tfp,"\\%o", *cp);
+ 		else
+ 		    fputc(*cp, tfp);
+ 	    }
+ 	} else {
+  	    int		state = 0;
+ 	    for(cp = (unsigned char *)t->cstring; *cp; cp++) {
+ 		if (state == 0 && *cp < 0x80) {
+ 		    if (strchr("()\\", *cp)) fputc('\\', tfp);
+ 		    fputc(*cp, tfp);
+ 		} else if (state == 1 && *cp < 0x80) {
+ 		    state = 0;
+ 		    fprintf(tfp,"\\377\\000");
+ 		    if (strchr("()\\", *cp)) fputc('\\', tfp);
+ 		    fputc(*cp, tfp);
+ 		} else if (state == 0 /* && *cp >= 0x80 */) {
+ 		    state = 1;
+ 		    fprintf(tfp,"\\377\\001");
+ 		    if (strchr("()\\", (*cp & 0x7f))) fputc('\\', tfp);
+ 		    fputc((*cp & 0x7f), tfp);
+ 		} else { /* state == 1 && *cp >= 0x80 */
+ 		    if (strchr("()\\", (*cp & 0x7f))) fputc('\\', tfp);
+ 		    fputc((*cp & 0x7f), tfp);
+ 		}
+ 	    }
+ 	}
+ #else
  	for(cp = (unsigned char *)t->cstring; *cp; cp++) {
  	    if (strchr("()\\", *cp))
  		fputc('\\', tfp);
***************
*** 1369,1374 ****
--- 1451,1457 ----
  	    else
  		fputc(*cp, tfp);
  		}
+ #endif
  	fputc(')', tfp);
  
  	if ((t->type == T_CENTER_JUSTIFIED) || (t->type == T_RIGHT_JUSTIFIED)){
***************
*** 1801,1806 ****
--- 1884,1915 ----
  	encode_all_fonts(c);
     }
  }
+ 
+ #ifdef KANJI
+ 
+ static encode_kanji_fonts(ob)
+ F_compound    *ob;
+ {
+    F_compound *c;
+    F_text     *t;
+    static int font_defined[ MAX_PSFONT ];
+ 
+    if (ob->texts != NULL)
+    {
+       for (t = ob->texts; t != NULL; t = t->next)
+       if (font_defined[t->font] != 1)
+       {
+          fprintf(tfp, "/%s /%s /%s-and-%s defineKanjiFont\n",
+                PSFONT(t), PSKANJIFONT(t), PSFONT(t), PSKANJIFONT(t));
+          font_defined[t->font] = 1;
+       }
+   }
+    
+   for (c = ob->compounds; c != NULL; c = c->next) {
+       encode_kanji_fonts(c);
+   }
+ }
+ #endif
  
  static
  ellipse_exist(ob)
*** ./fig2dev/dev/genps.h.orig	Thu Aug 10 06:11:04 1995
--- ./fig2dev/dev/genps.h	Fri Aug  9 10:22:03 1996
***************
*** 1139,1144 ****
--- 1139,1172 ----
  	savematrix setmatrix\n\
  	} def\n\
  "
+ 
+ 
+ #ifdef KANJI
+ #define KANJI_PROLOG "\n\
+ /defineKanjiFont % ascii-font kanji-font new-font-name\n\
+ {\n\
+     /name exch def\n\
+     findfont /fk exch def\n\
+     findfont /fn exch def\n\
+ \n\
+     12 dict begin\n\
+         /FontName name def\n\
+         /FontType 0 def\n\
+         /WMode 0 def\n\
+         /FMapType 3 def\n\
+         /FontMatrix matrix def\n\
+         /Encoding [0 1] def\n\
+         /EscChar  16#ff def\n\
+         /FDepVector [\n\
+             fn fk\n\
+         ] def\n\
+         FontName currentdict\n\
+     end definefont pop\n\
+ } def\n\
+ %%\n\
+ "
+ #endif
+ 
  /* The original PostScript definition for adding a spline section to the
   * current path uses recursive bisection.  The following definition using the
   * curveto operator is more efficient since it executes at compiled rather
*** ./fig2dev/psfonts.c.orig	Thu Feb 16 09:22:35 1995
--- ./fig2dev/psfonts.c	Fri Aug  9 10:14:09 1996
***************
*** 71,77 ****
  			"ZapfDingbats"
  		};
  
! static int	PSfontmap[] = {
  		ROMAN_FONT, ROMAN_FONT,	/* Times-Roman */
  		ITALIC_FONT,		/* Times-Italic */
  		BOLD_FONT,		/* Times-Bold */
--- 71,77 ----
  			"ZapfDingbats"
  		};
  
! int		PSfontmap[] = {
  		ROMAN_FONT, ROMAN_FONT,	/* Times-Roman */
  		ITALIC_FONT,		/* Times-Italic */
  		BOLD_FONT,		/* Times-Bold */
*** ./patchlevel.h.orig	Thu Aug 17 07:20:30 1995
--- ./patchlevel.h	Fri Aug  9 13:46:59 1996
***************
*** 18,21 ****
   */
  
  #define VERSION		"3.1"
! #define PATCHLEVEL	"2"
--- 18,21 ----
   */
  
  #define VERSION		"3.1"
! #define PATCHLEVEL	"2(J)"
