diff -urN chimera-1.70p1/Common.tmpl.dist chimera-1.70p1-jp-01/Common.tmpl.dist
--- chimera-1.70p1/Common.tmpl.dist	Mon May 26 06:44:03 1997
+++ chimera-1.70p1-jp-01/Common.tmpl.dist	Wed May 28 02:44:33 1997
@@ -120,4 +120,6 @@
 XRELEASE = 0
 #endif
 
+KANJI_DEFINES = -DCHIMERA_JP
+
 #define MyNull
diff -urN chimera-1.70p1/Imakefile chimera-1.70p1-jp-01/Imakefile
--- chimera-1.70p1/Imakefile	Sun Apr  2 12:38:56 1995
+++ chimera-1.70p1-jp-01/Imakefile	Wed May 28 02:44:33 1997
@@ -1,5 +1,5 @@
 #define IHaveSubDirs
-#define PassCDebugFlags 'CDEBUGFLAGS='
+#define PassCDebugFlags 'CDEBUGFLAGS=-g -O0'
 
 SUBDIRS = compat libhtmlw mxw xloadimage common src lib util
 
diff -urN chimera-1.70p1/README.CHIMERA_JP chimera-1.70p1-jp-01/README.CHIMERA_JP
--- chimera-1.70p1/README.CHIMERA_JP	Thu Jan  1 09:00:00 1970
+++ chimera-1.70p1-jp-01/README.CHIMERA_JP	Wed May 28 05:02:59 1997
@@ -0,0 +1,6 @@
+CHIMERA_JP patch includes patches written by many people and me
+to display Japanese characters for previous version (1.65 or earlier)
+of Chimera.
+
+Wed May 28 04:56:08 JST 1997
+Azuma OKAMOTO <lfo@sayori.dais.is.tohoku.ac.jp>
diff -urN chimera-1.70p1/compat/Imakefile chimera-1.70p1-jp-01/compat/Imakefile
--- chimera-1.70p1/compat/Imakefile	Tue Mar 14 12:48:00 1995
+++ chimera-1.70p1-jp-01/compat/Imakefile	Wed May 28 02:44:33 1997
@@ -31,7 +31,7 @@
 
 DependTarget()
 #else
-all:
+all::
 
 depend::
 #endif
diff -urN chimera-1.70p1/libhtmlw/HTML-PSformat.c chimera-1.70p1-jp-01/libhtmlw/HTML-PSformat.c
--- chimera-1.70p1/libhtmlw/HTML-PSformat.c	Mon May 26 06:44:03 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTML-PSformat.c	Wed May 28 02:44:33 1997
@@ -110,6 +110,13 @@
 		} \
 }
 
+/* Added by kazu@ftk.fujitsu.co.jp */
+#ifdef CHIMERA_JP
+#define NIHONGO_MASK	(1<<7)
+#define G2		0x8e
+#define G3		0x8f
+#define KANA_MASK	~(~0<<7)
+#endif /* CHIMERA_JP */
 
 /* for regular-font, bold-font, italic-font, fixed-font */
 typedef enum
@@ -269,8 +276,13 @@
  |
 */
 
+#ifdef CHIMERA_JP
+static void PSfont
+ARG3 (HTMLWidget, hw, XFontSet, font, int, fontfamily)
+#else /* CHIMERA_JP */
 static void PSfont 
 ARG3 (HTMLWidget, hw, XFontStruct *, font, int, fontfamily)
+#endif /* CHIMERA_JP */
 {
 
   PS_fontstyle fn;
@@ -285,6 +297,12 @@
 
   static char fnchar[6][3] =
   {"RF", "BF", "IF", "FF", "FB", "FI"};
+#ifdef CHIMERA_JP
+  static char kfnchar[6][4] =
+  {"KRF", "KBF", "KRF", "KBF", "KBF", "KRF"};
+  static char knfnchar[6][4] =
+  {"KNF", "KNF", "KNF", "KNF", "KNF", "KNF"};
+#endif /* CHIMERA_JP */
 
   /* fontsizes as set in gui.c and in HTML.c (listing font is only
    * defined in HTML.c)
@@ -369,7 +387,15 @@
   if (hw == NULL || font == NULL)
   {
     if (PS_oldfs != 0)
+    {
       PSprintf ("%2s %d SF\n", fnchar[PS_oldfn], PS_oldfs);
+#ifdef CHIMERA_JP
+      PSprintf( "/FN %2s D\n", fnchar[PS_oldfn]);
+      PSprintf( "/FNS %d D\n", PS_oldfs);
+      PSprintf( "/KFN %3s D\n", kfnchar[PS_oldfn]);
+      PSprintf( "/KNFN %3s D\n", knfnchar[PS_oldfn]);
+#endif /* CHIMERA_JP */
+    }
     return;
   }
   /* added the next line in case xmosaic version 199.4 has more fonts */
@@ -446,6 +472,18 @@
 
   /* check size, by looking at the size of the regular font */
   size = 1;
+#ifdef CHIMERA_JP
+  if (FontAscent(hw->html.bold_font) > medium_fontascent[fontfamily])
+  {
+    /* large font */
+    size = 2;
+  }
+  else if (FontAscent(hw->html.bold_font) < medium_fontascent[fontfamily])
+  {
+    /* small font */
+    size = 0;
+  }
+#else /* CHIMERA_JP */
   if (hw->html.bold_font->ascent > medium_fontascent[fontfamily])
   {
     /* large font */
@@ -456,6 +494,7 @@
     /* small font */
     size = 0;
   }
+#endif /* CHIMERA_JP */
   fn = fontstyle[style];
   fs = fontsizes[fontfamily][size][style];
   PS_fontascent = fontascent[fontfamily][size][style];
@@ -463,6 +502,12 @@
   if (fn != PS_oldfn || fs != PS_oldfs)
   {
     PSprintf ("%2s %d SF\n", fnchar[fn], fs);
+#ifdef CHIMERA_JP
+    PSprintf( "/FN %2s D\n", fnchar[fn]);
+    PSprintf( "/FNS %d D\n", fs);
+    PSprintf( "/KFN %3s D\n", kfnchar[fn]);
+    PSprintf( "/KNFN %3s D\n", knfnchar[fn]);
+#endif
     PS_oldfn = fn, PS_oldfs = fs;
   }
 }
@@ -611,8 +656,12 @@
   /* this is a nasty trick, I have put Times in place of
    * Lucida, becaus emost printers don't have Lucida font
    */
-    "Times-Roman", "Times-Bold", "Times-Italic"
-  /* "Lucida", "Lucida-Bold", "Lucida-Italic" */
+    "Times-Roman", "Times-Bold", "Times-Italic",
+  /* "Lucida", "Lucida-Bold", "Lucida-Italic", */
+#ifdef CHIMERA_JP
+    "Ryumin-Light-EUC-H","GothicBBB-Medium-EUC-H",
+    "Ryumin-Light.Katakana",
+#endif /* CHIMERA_JP */
   };
 
   static char *txt[] =
@@ -660,6 +709,11 @@
   PSprintf ("/RF {/%s} D\n", fontname[font * 3]);
   PSprintf ("/BF {/%s} D\n", fontname[font * 3 + 1]);
   PSprintf ("/IF {/%s} D\n", fontname[font * 3 + 2]);
+#ifdef CHIMERA_JP
+  PSprintf("/KRF {/%s} D\n", fontname[12]);
+  PSprintf("/KBF {/%s} D\n", fontname[13]);
+  PSprintf("/KNF {/%s} D\n", fontname[14]);
+#endif /* CHIMERA_JP */
 
   PSinit_latin1 ();
 
@@ -701,6 +755,9 @@
 {
   String tp, t2;
   int nspecial = 0, nisochar = 0;
+#ifdef CHIMERA_JP
+  void PSkprint();
+#endif /* CHIMERA_JP */
 
   tp = t;
   /* count # of special char's in text */
@@ -716,7 +773,11 @@
   if (nspecial == 0 && nisochar == 0)
   {
     /*  no special char's, send out original string */
+#ifdef CHIMERA_JP
+    PSkprint (t, (underline) ? 'U' : 'S');
+#else /* CHIMERA_JP */
     PSprintf ("(%s)%c\n", t, (underline) ? 'U' : 'S');
+#endif /* CHIMERA_JP */
     return;
   }
   /*  create t2 to hold original text + "\"'s */
@@ -741,6 +802,7 @@
       *(tp++) = B_SLASH;
       *(tp++) = *t;
     }
+#ifndef CHIMERA_JP
     else if (*(unsigned char *) t > (unsigned char) MAX_ASCII)
     {
       /*  convert to octal */
@@ -749,6 +811,7 @@
       *(tp++) = ((int) (*(unsigned char *) t) >> 3 & 007) + '0';
       *(tp++) = ((int) (*(unsigned char *) t) & 007) + '0';
     }
+#endif /* not CHIMERA_JP */
     else
     {
       *(tp++) = *t;
@@ -756,7 +819,11 @@
     t++;
   }
   *(tp) = '\0';
+#ifdef CHIMERA_JP
+  PSkprint (t2, (underline) ? 'U' : 'S');
+#else /* CHIMERA_JP */
   PSprintf ("(%s)%c\n", t2, (underline) ? 'U' : 'S');
+#endif /* CHIMERA_JP */
 
   XtFree(t2);
 }
@@ -1509,6 +1576,13 @@
     end = endp;
   }
 
+#ifdef CHIMERA_JP
+  if (start != NULL && start->type == E_TEXT)
+    SetByte1(start->edata, &start_pos);
+  if (end != NULL && end->type == E_TEXT)
+    SetByte2(end->edata, &end_pos);
+#endif /* CHIMERA_JP */
+
   /* Calculate the number of Postscript points per pixel of current
    * screen, and the height of the page in pixels (used in figuring
    * when we've hit the bottom of the page).
@@ -1595,7 +1669,11 @@
 
 	PSfont (hw, eptr->font, fontfamily);	/* set font */
 	if (PS_fontascent == 0)
+#ifdef CHIMERA_JP
+	  ascent = FontAscent(eptr->font);
+#else /* CHIMERA_JP */
 	  ascent = eptr->font->ascent;
+#endif /* CHIMERA_JP */
 	else
 	  ascent = PS_fontascent;
 	PSmove_offset (eptr->y_offset + ascent);
@@ -1609,8 +1687,12 @@
 	int offset;
 
 	PSfont (hw, eptr->font, fontfamily);
+#ifdef CHIMERA_JP
+	width = FontLogicalWidth(eptr->font);
+#else /* CHIMERA_JP */
 	width = eptr->font->max_bounds.lbearing +
 	  eptr->font->max_bounds.rbearing;
+#endif /* CHIMERA_JP */
 	/* the next line is a hack to get a good position of the
 	 * bullet in most practical cases, otherwise the
 	 * bullet may appear just a bit too low (for large fonts)
@@ -1623,9 +1705,17 @@
 	  offset = eptr->line_height -
 	    eptr->next->line_height +
 	    eptr->y_offset +
+#ifdef CHIMERA_JP
+	    FontAscent(eptr->next->font);
+#else /* CHIMERA_JP */
 	    eptr->next->font->ascent;
+#endif /* CHIMERA_JP */
 	else
+#ifdef CHIMERA_JP
+	  offset = eptr->y_offset + FontAscent(eptr->font);
+#else
 	  offset = eptr->y_offset + eptr->font->ascent;
+#endif /* CHIMERA_JP */
 
 	PSmove_offset (offset - width / 4);
 	PSbullet (eptr->indent_level, eptr->line_height);
@@ -1660,3 +1750,102 @@
 
   return (PS_string);
 }
+
+/* Follow lines added by kazu@ftk.fujitsu.co.jp */
+#ifdef CHIMERA_JP
+void
+PSkprint (text,command)
+unsigned char *text;
+unsigned char command;
+{
+  unsigned char *drawdata;
+  unsigned char *PS_DrawAscii(),*PS_DrawKana(),*PS_DrawGaiji(),*PS_DrawKanji();
+
+  drawdata = text;
+  while (*drawdata != '\0')
+  {
+    if (!(*drawdata & NIHONGO_MASK))
+    {
+      drawdata = PS_DrawAscii(drawdata,command);
+      continue;
+    }
+    if (*drawdata == G2)
+    {
+      drawdata = PS_DrawKana(drawdata,command);
+      continue;
+    }
+    if (*drawdata == G3)
+    {
+      drawdata = PS_DrawGaiji(drawdata,command);
+      continue;
+    }
+    drawdata = PS_DrawKanji(drawdata,command);
+  }
+}
+
+unsigned char *
+PS_DrawAscii(data,command)
+unsigned char *data;
+unsigned char command;
+{
+  PSprintf("(");
+  while (!(*data & NIHONGO_MASK) && *data != '\0')
+  {
+    PSprintf("%c",*data++);
+  }
+  PSprintf(")%c\n",command);
+  return (data);
+}
+
+unsigned char *
+PS_DrawKanji(data,command)
+unsigned char *data;
+unsigned char command;
+{
+  PSprintf("KFN findfont FNS scalefont setfont\n");
+  PSprintf("(");
+  while (*data & NIHONGO_MASK && *data != G2 && 
+         *data != G3 && *data != '\0')
+  {
+    PSprintf("%c%c",*data,*(data+1));
+    data += 2;
+  }
+  PSprintf(")%c\n",command);
+  PSprintf("FN findfont FNS scalefont setfont\n");
+  return (data);
+}
+
+unsigned char *
+PS_DrawKana(data,command)
+unsigned char *data;
+unsigned char command;
+{
+  PSprintf("KNFN findfont FNS scalefont setfont\n");
+  PSprintf("(");
+  while (*data == G2 && *data != '\0')
+  {
+    PSprintf("\\%o",(*++data) & KANA_MASK);
+    ++data;
+  }
+  PSprintf(")%c\n",command);
+  PSprintf("FN findfont FNS scalefont setfont\n");
+  return (data);
+}
+
+unsigned char *
+PS_DrawGaiji(data,command)
+unsigned char *data;
+unsigned char command;
+{
+  PSprintf("KFN findfont FNS scalefont setfont\n");
+  PSprintf("<");
+  while (*data == G3 && *data != '\0')
+  {
+    PSprintf("%x%x ",*++data,*++data);
+    ++data;
+  }
+  PSprintf(">%c\n",command);
+  PSprintf("FN findfont FNS scalefont setfont\n");
+  return (data);
+}
+#endif /* CHIMERA_JP */
diff -urN chimera-1.70p1/libhtmlw/HTML.c chimera-1.70p1-jp-01/libhtmlw/HTML.c
--- chimera-1.70p1/libhtmlw/HTML.c	Mon May 26 06:44:04 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTML.c	Wed May 28 04:46:27 1997
@@ -79,6 +79,9 @@
 #define	W_PASSWORD	4
 #define	W_OPTIONMENU	5
 
+#ifndef CHIMERA_JP
+#define FontLogicalWidth(f)	((f)->max_bounds.width)
+#endif
 
 extern int FormatAll ();
 extern int DocumentWidth ();
@@ -433,6 +436,118 @@
     XtOffset (HTMLWidget, html.hbar_top),
     XtRString, "False"
   },
+#ifdef CHIMERA_JP
+#define F14  "-adobe-times-medium-r-*--14-*,-*-*-medium-r-*--14-*"
+#define F14I "-adobe-times-medium-i-*--14-*,-*-*-medium-r-*--14-*"
+#define F14B "-adobe-times-bold-r-*--14-*,-*-*-medium-r-*--14-*"
+#define F16B "-adobe-times-bold-r-*--17-*,-*-*-medium-r-*--16-*"
+#define F24B "-adobe-times-bold-r-*--24-*,-*-*-medium-r-*--24-*"
+#define FFIX "-misc-*-medium-r-*--14-*"
+#define FFIXB "-misc-*-medium-r-*--14-*"
+#define FFIXI "-misc-*-medium-r-*--14-*"
+  {
+    XtNfontSet,
+    XtCFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.font),
+    XtRString, F14
+  },
+  {
+    WbNitalicFontSet,
+    WbCItalicFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.italic_font),
+    XtRString, F14I
+  },
+  {
+    WbNboldFontSet,
+    WbCBoldFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.bold_font),
+    XtRString, F14B
+  },
+  {
+    WbNfixedFontSet,
+    WbCFixedFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.fixed_font),
+    XtRString, FFIX
+  },
+  {
+    WbNfixedboldFontSet,
+    WbCFixedboldFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.fixedbold_font),
+    XtRString, FFIXB
+  },
+  {
+    WbNfixeditalicFontSet,
+    WbCFixeditalicFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.fixeditalic_font),
+    XtRString, FFIXI
+  },
+  {
+    WbNheader1FontSet,
+    WbCHeader1FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header1_font),
+    XtRString, F24B
+  },
+  {
+    WbNheader2FontSet,
+    WbCHeader2FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header2_font),
+    XtRString, F16B
+  },
+  {
+    WbNheader3FontSet,
+    WbCHeader3FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header3_font),
+    XtRString, F16B
+  },
+  {
+    WbNheader4FontSet,
+    WbCHeader4FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header4_font),
+    XtRString, F14B
+  },
+  {
+    WbNheader5FontSet,
+    WbCHeader5FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header5_font),
+    XtRString, F14B
+  },
+  {
+    WbNheader6FontSet,
+    WbCHeader6FontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.header6_font),
+    XtRString, F14B
+  },
+  {
+    WbNaddressFontSet,
+    WbCAddressFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.address_font),
+    XtRString, F14I
+  },
+  {
+    WbNplainFontSet,
+    WbCPlainFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.plain_font),
+    XtRString, FFIX
+  },
+  {
+    WbNplainboldFontSet,
+    WbCPlainboldFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.plainbold_font),
+    XtRString, FFIXB
+  },
+  {
+    WbNplainitalicFontSet,
+    WbCPlainitalicFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.plainitalic_font),
+    XtRString, FFIXI
+  },
+  {
+    WbNlistingFontSet,
+    WbCListingFontSet, XtRFontSet, sizeof (XFontSet),
+    XtOffset (HTMLWidget, html.listing_font),
+    XtRString, F14
+  },
+#else /* CHIMERA_JP */
   {
     XtNfont,
     XtCFont, XtRFontStruct, sizeof (XFontStruct *),
@@ -535,6 +650,7 @@
     XtOffset (HTMLWidget, html.listing_font),
     XtRString, "-adobe-courier-medium-r-normal-*-12-*-*-*-*-*-*-*"
   },
+#endif /* CHIMERA_JP */
   {
     WbNpreviouslyVisitedTestFunction,
     WbCPreviouslyVisitedTestFunction, XtRPointer,
@@ -1794,6 +1910,9 @@
   start = 0;
   end = hw->html.full_line_count - 1;
 
+#ifdef CHIMERA_JP
+  guess = end;
+#else /* CHIMERA_JP */
   /*
    * Heuristic to speed up redraws by guessing at the starting line.
    */
@@ -1803,6 +1922,7 @@
   {
     guess = end;
   }
+#endif /* CHIMERA_JP */
   while (guess > 0)
   {
     if ((hw->html.line_array[guess] != NULL) &&
@@ -2234,6 +2354,13 @@
     end_pos = epos;
   }
 
+#ifdef CHIMERA_JP
+  if (start != NULL && start->type == E_TEXT)
+    SetByte1(start->edata, &start_pos);
+  if (end != NULL && end->type == E_TEXT)
+    SetByte2(end->edata, &end_pos);
+#endif /* CHIMERA_JP */
+
   eptr = start;
   while ((eptr != NULL) && (eptr != end))
   {
@@ -2369,6 +2496,13 @@
     end_pos = epos;
   }
 
+#ifdef CHIMERA_JP
+  if (start != NULL && start->type == E_TEXT)
+    SetByte1(start->edata, &start_pos);
+  if (end != NULL && end->type == E_TEXT)
+    SetByte2(end->edata, &end_pos);
+#endif /* CHIMERA_JP */
+
   eptr = start;
   while ((eptr != NULL) && (eptr != end))
   {
@@ -3230,7 +3364,7 @@
 				  hw->html.select_end,
 				  hw->html.sel_start_pos,
 				  hw->html.sel_end_pos,
-				  hw->html.font->max_bounds.width);
+				  FontLogicalWidth(hw->html.font));
 	XStoreBuffer (XtDisplay ((Widget) hw),
 		      text, strlen (text), buffer);
 	if (text != NULL)
@@ -3518,8 +3652,8 @@
 	 */
 	tptr = ParseTextToString (NULL,
 				  hw->html.select_start, hw->html.select_end,
-				 hw->html.sel_start_pos, hw->html.sel_end_pos,
-				  hw->html.font->max_bounds.width);
+				  hw->html.sel_start_pos, hw->html.sel_end_pos,
+				  FontLogicalWidth(hw->html.font));
 	ptr = tptr;
 	while ((ptr != NULL) && (*ptr != '\0'))
 	{
@@ -3864,7 +3998,20 @@
     text = ParseTextToString ((hw->html.fancy_selections == True) ? hw : NULL,
 			      hw->html.select_start, hw->html.select_end,
 			      hw->html.sel_start_pos, hw->html.sel_end_pos,
-			      hw->html.font->max_bounds.width);
+			      FontLogicalWidth(hw->html.font));
+#ifdef CHIMERA_JP
+    if (*target == XA_COMPOUND_TEXT(d) || *target == XA_TEXT(d)) {
+      char *ctext;
+      int mblen, clength, dummy1, dummy2;
+      XTextProperty xtp;
+      
+      *type = XA_COMPOUND_TEXT(d);
+      XmbTextListToTextProperty(d, &text, 1, XCompoundTextStyle, &xtp);
+      text = (char*)realloc(text, strlen(xtp.value));
+      strcpy(text, xtp.value);
+      XFree(xtp.value);
+    } 
+#endif /* CHIMERA_JP */
     *value = text;
     *length = strlen (*value);
     *format = 8;
@@ -3894,7 +4041,7 @@
     text = ParseTextToString ((hw->html.fancy_selections == True) ? hw : NULL,
 			      hw->html.select_start, hw->html.select_end,
 			      hw->html.sel_start_pos, hw->html.sel_end_pos,
-			      hw->html.font->max_bounds.width);
+			      FontLogicalWidth(hw->html.font));
     *value = XtMalloc (4);
     if (sizeof (long) == 4)
     {
@@ -3989,13 +4136,13 @@
   if (pretty >= 2)
   {
     tptr = ParseTextToPSString (hw, start, end, 0, 0,
-				hw->html.font->max_bounds.width,
+				FontLogicalWidth(hw->html.font),
 				hw->html.margin_width, pretty - 2);
   }
   else
   {
     tptr = ParseTextToString (pretty ? hw : NULL, start, end, 0, 0,
-			      hw->html.font->max_bounds.width);
+			      FontLogicalWidth(hw->html.font));
   }
   if (tptr != NULL)
   {
@@ -4802,7 +4949,7 @@
 				hw->html.select_end,
 				hw->html.sel_start_pos,
 				hw->html.sel_end_pos,
-				hw->html.font->max_bounds.width);
+				FontLogicalWidth(hw->html.font));
       XStoreBuffer (XtDisplay ((Widget) hw),
 		    text, strlen (text), buffer);
       XtFree (text);
@@ -4859,6 +5006,13 @@
     end_pos = hw->html.sel_end_pos;
   }
 
+#ifdef CHIMERA_JP
+  if (sel_start != NULL && sel_start->type == E_TEXT)
+    SetByte1(sel_start->edata, &start_pos);
+  if (sel_end != NULL && sel_end->type == E_TEXT)
+    SetByte2(sel_end->edata, &end_pos);
+#endif /* CHIMERA_JP */
+
   insert_start = hw->html.new_start;
   insert_pos = hw->html.new_start_pos;
   *startp = NULL;
@@ -5556,6 +5710,44 @@
     return (-1);
   }
 }
+
+#ifdef CHIMERA_JP
+SetByte1(text, pos)
+char *text;
+int  *pos;
+{
+  int i, prev;
+
+  i = prev = 0;
+  while (text[i] && i <= *pos)
+  {
+    prev = i;
+    if (text[i] & 0x80)
+      i += 2;
+    else
+      i++;
+  }
+  *pos = prev;
+}
+
+SetByte2(text, pos)
+char *text;
+int  *pos;
+{
+  int i, prev;
+
+  i = prev = 0;
+  while (text[i] && i <= *pos)
+  {
+    prev = i;
+    if (text[i] & 0x80)
+      i += 2;
+    else
+      i++;
+  }
+  *pos = (prev + i) >> 1;
+}
+#endif /* CHIMERA_JP */
 
 
 /* added this - djhjr - May 19 97 */
diff -urN chimera-1.70p1/libhtmlw/HTML.h chimera-1.70p1-jp-01/libhtmlw/HTML.h
--- chimera-1.70p1/libhtmlw/HTML.h	Mon May 26 06:44:04 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTML.h	Wed May 28 02:44:34 1997
@@ -184,7 +184,11 @@
 	int type;
 	IMGInfo *img_data;
 	WidgetInfo *widget_data;
+#ifdef CHIMERA_JP
+	XFontSet font;
+#else /* CHIMERA_JP */
 	XFontStruct *font;
+#endif /* CHIMERA_JP */
 	int alignment;
 	Boolean internal;
 	Boolean selected;
@@ -366,6 +370,24 @@
 #define WbNhtmlErrorMsgCutoff   "htmlErrorMsgCutoff"
 #define WbNtruncateALT          "truncateALT"
 #define	WbNisIndex		"isIndex"
+#ifdef CHIMERA_JP
+#define	WbNitalicFontSet	"italicFontSet"
+#define	WbNboldFontSet		"boldFontSet"
+#define	WbNfixedFontSet		"fixedFontSet"
+#define	WbNfixedboldFontSet	"fixedboldFontSet"
+#define	WbNfixeditalicFontSet	"fixeditalicFontSet"
+#define	WbNheader1FontSet	"header1FontSet"
+#define	WbNheader2FontSet	"header2FontSet"
+#define	WbNheader3FontSet	"header3FontSet"
+#define	WbNheader4FontSet	"header4FontSet"
+#define	WbNheader5FontSet	"header5FontSet"
+#define	WbNheader6FontSet	"header6FontSet"
+#define	WbNaddressFontSet	"addressFontSet"
+#define	WbNplainFontSet		"plainFontSet"
+#define	WbNplainboldFontSet	"plainboldFontSet"
+#define	WbNplainitalicFontSet	"plainitalicFontSet"
+#define	WbNlistingFontSet	"listingFontSet"
+#else /* CHIMERA_JP */
 #define	WbNitalicFont		"italicFont"
 #define	WbNboldFont		"boldFont"
 #define	WbNfixedFont		"fixedFont"
@@ -382,6 +404,7 @@
 #define	WbNplainboldFont	"plainboldFont"
 #define	WbNplainitalicFont	"plainitalicFont"
 #define	WbNlistingFont		"listingFont"
+#endif /* CHIMERA_JP */
 #define	WbNanchorCallback	"anchorCallback"
 #define	WbNlinkCallback		"linkCallback"
 #define	WbNsubmitFormCallback	"submitFormCallback"
@@ -423,6 +446,24 @@
 #define WbCHTMLErrorMsgCutoff   "HTMLErrorMsgCutoff"
 #define WbCTruncateALT          "TruncateALT"
 #define	WbCIsIndex		"IsIndex"
+#ifdef CHIMERA_JP
+#define	WbCItalicFontSet	"ItalicFontSet"
+#define	WbCBoldFontSet		"BoldFontSet"
+#define	WbCFixedFontSet		"FixedFontSet"
+#define	WbCFixedboldFontSet	"FixedboldFontSet"
+#define	WbCFixeditalicFontSet	"FixeditalicFontSet"
+#define	WbCHeader1FontSet	"Header1FontSet"
+#define	WbCHeader2FontSet	"Header2FontSet"
+#define	WbCHeader3FontSet	"Header3FontSet"
+#define	WbCHeader4FontSet	"Header4FontSet"
+#define	WbCHeader5FontSet	"Header5FontSet"
+#define	WbCHeader6FontSet	"Header6FontSet"
+#define	WbCAddressFontSet	"AddressFontSet"
+#define	WbCPlainFontSet		"PlainFontSet"
+#define	WbCPlainboldFontSet	"PlainboldFontSet"
+#define	WbCPlainitalicFontSet	"PlainitalicFontSet"
+#define	WbCListingFontSet	"ListingFontSet"
+#else /* CHIMERA_JP */
 #define	WbCItalicFont		"ItalicFont"
 #define	WbCBoldFont		"BoldFont"
 #define	WbCFixedFont		"FixedFont"
@@ -439,6 +480,7 @@
 #define	WbCPlainboldFont	"PlainboldFont"
 #define	WbCPlainitalicFont	"PlainitalicFont"
 #define	WbCListingFont		"ListingFont"
+#endif /* CHIMERA_JP */
 #define	WbCPreviouslyVisitedTestFunction "PreviouslyVisitedTestFunction"
 #define	WbCResolveImageFunction "ResolveImageFunction"
 #define	WbCResolveDelayedImage "ResolveDelayedImage"
diff -urN chimera-1.70p1/libhtmlw/HTMLP.h chimera-1.70p1-jp-01/libhtmlw/HTMLP.h
--- chimera-1.70p1/libhtmlw/HTMLP.h	Mon May 26 06:44:04 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTMLP.h	Wed May 28 02:44:34 1997
@@ -135,6 +135,25 @@
 	int                     truncate_alt;
 	int			percent_vert_space;
 
+#ifdef CHIMERA_JP
+	XFontSet		font;
+	XFontSet		italic_font;
+	XFontSet		bold_font;
+	XFontSet		fixed_font;
+	XFontSet		fixedbold_font;
+	XFontSet		fixeditalic_font;
+	XFontSet		header1_font;
+	XFontSet		header2_font;
+	XFontSet		header3_font;
+	XFontSet		header4_font;
+	XFontSet		header5_font;
+	XFontSet		header6_font;
+	XFontSet		address_font;
+	XFontSet		plain_font;
+	XFontSet		plainbold_font;
+	XFontSet		plainitalic_font;
+	XFontSet		listing_font;
+#else /* CHIMERA_JP */
 	XFontStruct		*font;
 	XFontStruct		*italic_font;
 	XFontStruct		*bold_font;
@@ -152,6 +171,7 @@
 	XFontStruct		*plainbold_font;
 	XFontStruct		*plainitalic_font;
 	XFontStruct		*listing_font;
+#endif /* CHIMERA_JP */
 
         XtPointer		previously_visited_test;
         XtPointer		resolveImage;
diff -urN chimera-1.70p1/libhtmlw/HTMLformat.c chimera-1.70p1-jp-01/libhtmlw/HTMLformat.c
--- chimera-1.70p1/libhtmlw/HTMLformat.c	Mon May 26 06:44:04 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTMLformat.c	Wed May 28 04:42:34 1997
@@ -69,6 +69,13 @@
 
 #include "HTMLP.h"
 
+#ifdef CHIMERA_JP
+#include <X11/Xlocale.h>
+#else /* CHIMERA_JP */
+#define FontAscent(f)	((f)->max_bounds.ascent)
+#define FontWidth(f)	((f)->max_bounds.width)
+#endif /* CHIMERA_JP */
+
 /* export */ int errors_in_HTML_document;
 
 #define Max(a,b) (((a) > (b)) ?  (a) : (b))
@@ -111,7 +118,11 @@
 extern void WidgetRefresh ();
 extern void MoveWidget (/*WidgetInfo *wp, x, y*/);
 extern WidgetInfo *MakeWidget ();
+#ifdef CHIMERA_JP
+extern XFontSet GetWidgetFont ();
+#else /* CHIMERA_JP */
 extern XFontStruct *GetWidgetFont ();
+#endif /* CHIMERA_JP */
 extern void AddNewForm ();
 extern void FreeOneForm ();
 extern void PrepareFormEnd ();
@@ -139,7 +150,11 @@
  */
 typedef struct font_rec
 {
+#ifdef CHIMERA_JP
+  XFontSet font;
+#else /* CHIMERA_JP */
   XFontStruct *font;
+#endif /* CHIMERA_JP */
   struct font_rec *next;
 }
 FontRec;
@@ -149,8 +164,13 @@
 static DescRec *ListData;
 static FontRec FontBase;
 static FontRec *FontStack;
+#ifdef CHIMERA_JP
+static XFontSet currentFont;
+static XFontSet saveFont;
+#else /* CHIMERA_JP */
 static XFontStruct *currentFont;
 static XFontStruct *saveFont;
+#endif /* CHIMERA_JP */
 static unsigned long Fg;
 static unsigned long Bg;
 static int Width;
@@ -213,6 +233,10 @@
 static int CompLineLen = 0;
 static char *CompWord = NULL;
 static int CompWordLen = 0;
+
+#ifdef CHIMERA_JP
+#define XTextExtents(f,s,n,d,fa,fd,o)	TextExtents(f,s,n,d,fa,fd,o)
+#endif /* CHIMERA_JP */
 
 /*
  * HaveRealBaseLine
@@ -255,14 +279,18 @@
 AddFElement (hw, type, fp, x, y, edata)
 HTMLWidget hw;
 int type;
+#ifdef CHIMERA_JP
+XFontSet fp;
+#else /* CHIMERA_JP */
 XFontStruct *fp;
+#endif /* CHIMERA_JP */
 int x, y;
 char *edata;
 {
   struct ele_rec *eptr;
   char *saved_edata;
   int len, saved_edata_len;
-  int baseline = (fp != NULL) ?  fp->max_bounds.ascent : LineHeight;
+  int baseline = (fp != NULL) ?  FontAscent(fp) : LineHeight;
 
   EmptyRegion = False;		/* there's about to be at least 1 element */
 
@@ -393,7 +421,11 @@
      * Deal with bad Lucida descents.
      */
 #ifdef NO_EXTRA_FILLS
+#ifdef CHIMERA_JP
+    eptr->line_height = FontHeight(eptr->font);
+#else /* CHIMERA_JP */
     eptr->line_height = eptr->font->ascent + eptr->font->descent;
+#endif /* CHIMERA_JP */
 #else
     eptr->line_height = LineHeight;
 #endif /* NO_EXTRA_FILLS */
@@ -522,8 +554,15 @@
  */
 void
 NewFont (fp)
+#ifdef CHIMERA_JP
+XFontSet fp;
+#else
 XFontStruct *fp;
+#endif
 {
+#ifdef CHIMERA_JP
+  LineHeight = FontHeight(fp);
+#else /* CHIMERA_JP */
   /*
    * Deal with bad Lucida descents.
    */
@@ -535,6 +574,7 @@
   {
     LineHeight = fp->max_bounds.ascent + fp->max_bounds.descent;
   }
+#endif /* CHIMERA_JP */
 }
 
 
@@ -755,7 +795,7 @@
 static void
 AdjustBaseLine ()
 {
-  int baseline = Current->font->max_bounds.ascent;
+  int baseline = FontAscent(Current->font);
 
 #ifdef DEBUG_ADJUSTBASELINE
   printf (" ABL baseline= %d, Baseline= %d, LB= %d, LH= %d\n",
@@ -807,8 +847,12 @@
 HTMLWidget hw;
 int *x, *y;
 {
+#ifdef CHIMERA_JP
+  int width = FontWidth(hw->html.font);
+#else /* CHIMERA_JP */
   int width = hw->html.font->max_bounds.lbearing
             + hw->html.font->max_bounds.rbearing;
+#endif /* CHIMERA_JP */
 
   /*
    * Save the font's line height, and set your own for this
@@ -817,8 +861,12 @@
    */
   int savedLineHeight = LineHeight;
 
+#ifdef CHIMERA_JP
+  LineHeight = FontHeight(hw->html.font);
+#else /* CHIMERA_JP */
   LineHeight = hw->html.font->max_bounds.ascent
       + Max (hw->html.font->descent, hw->html.font->max_bounds.descent);
+#endif /* CHIMERA_JP */
 
   /*
    * For historical reasons, bullets aren't between *x and *x + width
@@ -896,8 +944,12 @@
 
   sprintf (buf, "%d.", val);
 
+#ifdef CHIMERA_JP
+  width = FontWidth(hw->html.font);
+#else /* CHIMERA_JP */
   width = hw->html.font->max_bounds.lbearing
       + hw->html.font->max_bounds.rbearing;
+#endif /* CHIMERA_JP */
 
   XTextExtents (currentFont, buf, strlen (buf), &dir, &ascent, &descent, &all);
   my_x = *x - (width / 2) - all.width;
@@ -1061,7 +1113,7 @@
       }
 
 #ifdef ASSUME_FIXED_WIDTH_PRE
-      all.width = currentFont->max_bounds.width * strlen (ptr);
+      all.width = FontWidth(currentFont) * strlen (ptr);
 #else
       XTextExtents (currentFont, ptr, strlen (ptr), &dir,
 		    &ascent, &descent, &all);
@@ -1204,6 +1256,11 @@
   char *line;
   int line_x0;
   int marginw = (CurrentTable != NULL) ?  0 : MarginW;
+#ifdef CHIMERA_JP
+  int after_kanji, is_wide;
+  is_wide = strncmp(setlocale(LC_CTYPE, NULL), "lt_LN", 5);
+  after_kanji = 1;
+#endif /* CHIMERA_JP */
 
   line_x0 = *x;
   line = CompLine;
@@ -1222,6 +1279,11 @@
     stripped_space = 0;
     added_space = 0;
     start = end;
+#ifdef CHIMERA_JP
+    if (is_wide && after_kanji && *start == '\n')
+      start++;
+    after_kanji = 0;
+#endif /* CHIMERA_JP */
     /*
      * the only reason I can see for the  < 128  test is
      * to make \240 work for &nbsp.  (WBE)
@@ -1236,6 +1298,15 @@
     end = start;
     while ((unsigned) *end > 127  ||  *end != '\0'  &&  !isspace (*end))
     {
+#ifdef CHIMERA_JP
+      if (is_wide && (unsigned char)*end > 127 && *(end + 1) != '\0')
+      {
+	end += 2;
+	after_kanji = 1;
+	NeedSpace = 0;
+	break;
+      }
+#endif /* CHIMERA_JP */
       end++;
     }
 
@@ -1269,7 +1340,7 @@
       }
       ptr = CompWord;
 
-      if (NeedSpace < 0  ||  (NeedSpace > 0  &&  Current->type != E_TEXT))
+      if (NeedSpace < 0  ||  (NeedSpace > 0  && Current != NULL && Current->type != E_TEXT))
       {
 	if (NeedSpace == 2  ||  NeedSpace == -2)
 	{
@@ -1856,7 +1927,11 @@
    */
   if (Current->widget_data != NULL)
   {
+#ifdef CHIMERA_JP
+    XFontSet fp;
+#else /* CHIMERA_JP */
     XFontStruct *fp;
+#endif /* CHIMERA_JP */
     int baseline;
 
     int extra = 2 * IMAGE_BORDER;
@@ -1875,8 +1950,12 @@
      */
     else
     {
+#ifdef CHIMERA_JP
+      int border = (dy - FontHeight(fp));
+#else /* CHIMERA_JP */
       int border = (dy - (fp->max_bounds.ascent + fp->max_bounds.descent));
-      baseline = (border / 2) + fp->max_bounds.ascent;
+#endif /* CHIMERA_JP */
+      baseline = (border / 2) + FontAscent(fp);
     }
 
     if (BaseLine == -100)	/* the special unset baseline value */
@@ -1953,7 +2032,11 @@
 
 static void
 PushFont (font)
+#ifdef CHIMERA_JP
+XFontSet font;
+#else /* CHIMERA_JP */
 XFontStruct *font;
+#endif /* CHIMERA_JP */
 {
   FontRec *fptr;
 #ifdef DEBUG_PUSHFONT
@@ -1966,10 +2049,18 @@
 }
 
 
+#ifdef CHIMERA_JP
+static XFontSet
+#else /* CHIMERA_JP */
 static XFontStruct *
+#endif /* CHIMERA_JP */
 PopFont ()
 {
+#ifdef CHIMERA_JP
+  XFontSet font;
+#else /* CHIMERA_JP */
   XFontStruct *font;
+#endif /* CHIMERA_JP */
   FontRec *fptr;
 
   if (FontStack->next != NULL)
@@ -2014,7 +2105,11 @@
 HTMLWidget hw;
 int *x, *y;
 const char *msg;
+#ifdef CHIMERA_JP
+XFontSet font;
+#else /* CHIMERA_JP */
 XFontStruct *font;
+#endif /* CHIMERA_JP */
 unsigned int xmax;
 Boolean center;
 {
@@ -2734,7 +2829,11 @@
 int *x, *y;
 {
   struct mark_up *mark;
+#ifdef CHIMERA_JP
+  XFontSet font;
+#else /* CHIMERA_JP */
   XFontStruct *font;
+#endif /* CHIMERA_JP */
   int type, width;
   
   mark = mptr;
@@ -3641,7 +3740,7 @@
   case M_MENU:
   case M_DIRECTORY:
     ConditionalLineFeed (hw, x, y, 1);
-    width = hw->html.font->max_bounds.width;
+    width = FontWidth(hw->html.font);
 #if 0
     /*
      * If this is the outermost level of indentation,
@@ -3866,7 +3965,7 @@
   case M_DESC_LIST:
     ConditionalLineFeed (hw, x, y, 1);
     ConditionalLineFeed (hw, x, y, 2);
-    width = hw->html.font->max_bounds.width;
+    width = FontWidth(hw->html.font);
     if (mark->is_end)
     {
       if (DescType->type == D_TEXT)
@@ -3942,7 +4041,7 @@
 
   case M_DESC_TITLE:
     ConditionalLineFeed (hw, x, y, 1);
-    width = hw->html.font->max_bounds.width;
+    width = FontWidth(hw->html.font);
     /*
      * Special hack.  Don't indent again for
      * multiple <dt>'s in a row.
@@ -3960,7 +4059,7 @@
     break;
 
   case M_DESC_TEXT:
-    width = hw->html.font->max_bounds.width;
+    width = FontWidth(hw->html.font);
 
     /*
      * For a compact list we want to stay on the same
@@ -4604,6 +4703,10 @@
       width = hw->core.width - x1;
     }
   }
+#ifdef CHIMERA_JP
+  y1 = eptr->y + eptr->y_offset;
+  height = FontHeight(eptr->font);
+#else /* CHIMERA_JP */
 #ifdef NO_EXTRA_FILLS
   /*
    * The actual height of the rectangle to fill is strange, based
@@ -4640,6 +4743,7 @@
 #endif /* SHORT_LINEFEEDS */
 
 #endif /* NO_EXTRA_FILLS */
+#endif /* CHIMERA_JP */
 
   x1 = x1 - hw->html.scroll_x;
   y1 = y1 - hw->html.scroll_y;
@@ -4675,8 +4779,10 @@
   int x, y, width;
   int partial;
 
+#ifndef CHIMERA_JP
   XSetFont (XtDisplay (hw), hw->html.drawGC, eptr->font->fid);
-  ascent = eptr->font->max_bounds.ascent;
+#endif /* CHIMERA_JP */
+  ascent = FontAscent(eptr->font);
   width = -1;
   partial = 0;
 
@@ -4688,7 +4794,7 @@
 #ifdef ASSUME_FIXED_WIDTH_PRE
     if (eptr->font == hw->html.plain_font)
     {
-      all.width = eptr->font->max_bounds.width * start_pos;
+      all.width = FontWidth(eptr->font) * start_pos;
     }
     else
     {
@@ -4743,7 +4849,7 @@
 #ifdef ASSUME_FIXED_WIDTH_PRE
       if (eptr->font == hw->html.plain_font)
       {
-	all.width = eptr->font->max_bounds.width * tlen;
+	all.width = FontWidth(eptr->font) * tlen;
       }
       else
       {
@@ -4758,6 +4864,13 @@
 
     XSetForeground (XtDisplay (hw), hw->html.drawGC, bg);
 
+#ifdef CHIMERA_JP
+    XFillRectangle(XtDisplay(hw->html.view),
+		   XtWindow(hw->html.view),
+		   hw->html.drawGC, x, y,
+		   (unsigned int) all.width,
+		   (unsigned int) FontHeight(eptr->font));
+#else /* CHIMERA_JP */
     height = (eptr->font->max_bounds.ascent - eptr->font->ascent);
     if (height > 0)
     {
@@ -4777,6 +4890,7 @@
 		      (unsigned int) all.width, (unsigned int) height);
     }
     width = all.width;
+#endif /* CHIMERA_JP */
   }
 #endif /* NO_EXTRA_FILLS */
 
@@ -4784,15 +4898,31 @@
   XSetBackground (XtDisplay (hw), hw->html.drawGC, bg);
 
   if (sip > 0)
+#ifdef CHIMERA_JP
+    XmbDrawImageString (XtDisplay (hw->html.view), XtWindow (hw->html.view),
+			eptr->font,
+			hw->html.drawGC,
+			x, y + ascent,
+			(char *) tdata, tlen);
+#else /* CHIMERA_JP */
     XDrawImageString (XtDisplay (hw->html.view), XtWindow (hw->html.view),
 		      hw->html.drawGC,
 		      x, y + ascent,
 		      (char *) tdata, tlen);
+#endif /* CHIMERA_JP */
   if (sip != 1)
+#ifdef CHIMERA_JP
+    XmbDrawString (XtDisplay (hw->html.view), XtWindow (hw->html.view),
+		      eptr->font,
+		      hw->html.drawGC,
+		      x, y + ascent,
+		      (char *) tdata, tlen);
+#else /* CHIMERA_JP */
     XDrawString (XtDisplay (hw->html.view), XtWindow (hw->html.view),
 		      hw->html.drawGC,
 		      x, y + ascent,
 		      (char *) tdata, tlen);
+#endif /* CHIMERA_JP */
 
   if (eptr->underline_number)
   {
@@ -4817,7 +4947,7 @@
 #ifdef ASSUME_FIXED_WIDTH_PRE
       if (eptr->font == hw->html.plain_font)
       {
-	all.width = eptr->font->max_bounds.width * tlen;
+	all.width = FontWidth(eptr->font) * tlen;
       }
       else
       {
@@ -4831,8 +4961,12 @@
       width = all.width;
     }
 
+#ifdef CHIMERA_JP
+    ly = (int) (y + FontHeight(eptr->font) - 1);
+#else /* CHIMERA_JP */
     ly = (int) (y + eptr->font->max_bounds.ascent +
 		eptr->font->descent - 1);
+#endif /* CHIMERA_JP */
 
     for (i = 0; i < eptr->underline_number; i++)
     {
@@ -4858,7 +4992,7 @@
 #ifdef ASSUME_FIXED_WIDTH_PRE
       if (eptr->font == hw->html.plain_font)
       {
-	all.width = eptr->font->max_bounds.width * tlen;
+	all.width = FontWidth(eptr->font) * tlen;
       }
       else
       {
@@ -4872,10 +5006,15 @@
       width = all.width;
     }
 
+#ifdef CHIMERA_JP
+    ly = (int) (y + FontHeight(eptr->font) - 1);
+    ly = ly - (FontHeight(hw->html.font) / 2);
+#else /* CHIMERA_JP */
     ly = (int) (y + eptr->font->max_bounds.ascent +
 		eptr->font->descent - 1);
     ly = ly - ((hw->html.font->max_bounds.ascent +
 		hw->html.font->descent) / 2);
+#endif /* CHIMERA_JP */
 
     XDrawLine (XtDisplay (hw->html.view), XtWindow (hw->html.view),
 	       hw->html.drawGC,
@@ -4942,7 +5081,9 @@
   y1 = eptr->y + eptr->y_offset + (line_height / 2) - (width / 4);
   x1 -= hw->html.scroll_x;
   y1 -= hw->html.scroll_y;
+#ifndef CHIMERA_JP
   XSetFont (XtDisplay (hw), hw->html.drawGC, eptr->font->fid);
+#endif /* !CHIMERA_JP */
   XSetForeground (XtDisplay (hw), hw->html.drawGC, eptr->fg);
   XSetBackground (XtDisplay (hw), hw->html.drawGC, eptr->bg);
   if (eptr->indent_level < 2)
@@ -5260,12 +5401,16 @@
    * overestimates if there are large objects or tables.  Still, the larger
    * the document, the more likely this estimate will speed up the search.
    */
+#ifdef CHIMERA_JP
+  guess = hw->html.doc_line_count - 1;
+#else /* CHIMERA_JP */
   guess = y / (hw->html.font->max_bounds.ascent +
 	       hw->html.font->max_bounds.descent);
   if (guess > (hw->html.doc_line_count - 1))
   {
     guess = hw->html.doc_line_count - 1;
   }
+#endif /* CHIMERA_JP */
   while (guess > 0)
   {
     if ((hw->html.line_array[guess] != NULL) &&
@@ -5466,7 +5611,7 @@
        * always be <= to this, but just in case, start at the end
        * of the string if it is not.
        */
-      epos = ((x - rptr->x) / rptr->font->max_bounds.width) + 1;
+      epos = ((x - rptr->x) / FontWidth(rptr->font)) + 1;
       if (epos >= rptr->edata_len - 1)
       {
 	epos = rptr->edata_len - 2;
@@ -5607,6 +5752,13 @@
     end = endp;
   }
 
+#ifdef CHIMERA_JP
+  if (start != NULL && start->type == E_TEXT)
+    SetByte1(start->edata, &start_pos);
+  if (end != NULL && end->type == E_TEXT)
+    SetByte2(end->edata, &end_pos);
+#endif /* CHIMERA_JP */
+
   if (pretty)
   {
     /*
@@ -5977,8 +6129,8 @@
     }
     mptr = mptr->next;
   }
-  width = pwidth * hw->html.plain_font->max_bounds.width;
-  lwidth = lwidth * hw->html.listing_font->max_bounds.width;
+  width = pwidth * FontWidth(hw->html.plain_font);
+  lwidth = lwidth * FontWidth(hw->html.listing_font);
   if (lwidth > width)
   {
     width = lwidth;
@@ -6036,3 +6188,79 @@
 
   return (False);
 }
+
+#ifdef CHIMERA_JP
+int
+FontWidth(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_ink_extent.width;
+}
+
+int
+FontLogicalWidth(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_logical_extent.width;
+}
+
+int
+FontHeight(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_ink_extent.height;
+}
+
+int
+FontLogicalHeight(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_logical_extent.height;
+}
+
+int
+FontAscent(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return -ext->max_ink_extent.y;
+}
+
+int
+FontLogicalAscent(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return -ext->max_logical_extent.y;
+}
+
+int
+FontDescent(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_ink_extent.height + ext->max_ink_extent.y;
+}
+int
+FontLogicalDescent(fs)
+XFontSet fs;
+{
+  XFontSetExtents *ext = XExtentsOfFontSet(fs);
+  return ext->max_logical_extent.height + ext->max_logical_extent.y;
+}
+
+TextExtents(fs, str, len, dir, ascent, descent, all)
+XFontSet fs;
+char *str;
+int len, *dir, *ascent, *descent;
+XCharStruct *all;
+{
+  XRectangle logical, ink;
+  XmbTextExtents(fs, str, len, &ink, &logical);
+  all->width = logical.width;
+}
+#endif /* CHIMERA_JP */
diff -urN chimera-1.70p1/libhtmlw/HTMLparse.c chimera-1.70p1-jp-01/libhtmlw/HTMLparse.c
--- chimera-1.70p1/libhtmlw/HTMLparse.c	Mon May 26 06:44:05 1997
+++ chimera-1.70p1-jp-01/libhtmlw/HTMLparse.c	Wed May 28 03:33:41 1997
@@ -801,6 +801,10 @@
   struct mark_up *mark;
   struct mark_up *list;
   struct mark_up *current;
+#ifdef CHIMERA_JP
+  char *p, *q, *new_str;
+  int shift_jis;
+#endif /* CHIMERA_JP */
 #ifdef TIMING
   gettimeofday (&Tv, &Tz);
   fprintf (stderr, "HTMLParse enter (%d.%d)\n", Tv.tv_sec, Tv.tv_usec);
@@ -818,6 +822,102 @@
     return (NULL);
   }
 
+#ifdef CHIMERA_JP
+  p = str;
+  shift_jis = 0;
+  while (*p)
+  {
+    if ((*p & 0xe0) == 0x80)
+    {
+      shift_jis = 1; /* maybe ... */
+      break;
+    }
+    p++;
+  }
+  p = str;
+  if (shift_jis)
+  {
+    q = new_str = (char*)malloc(strlen(str) * 2 + 1);
+    while (*p)
+    {
+      if ((*p & 0x80) == 0)
+      {
+	*q++ = *p++;
+      }
+      else
+      {
+	char c0, c1;
+	c0 = *p++ & 0x7f;
+        if (0x20 <= c0 && c0 <= 0x5f)
+        {
+          *q++ = 0x8e; /* SS2 */
+	  *q++ = c0;
+	}
+	else if (0x00 <= c0 && c0 <= 0x1f)
+	{
+	  ;
+	}
+	else if (0x60 <= c0 && c0 <= 0x6f)
+	{
+	  c0 -= 0x40;
+	}
+	else
+	{
+	  *q++ = '?';
+	  continue;
+	}
+	c0 <<= 1;
+	c1 = *p++;
+	if ((unsigned char) c1 < 0x9f)
+	{
+	  if ((unsigned char) c1 > 0x7e)
+	  {
+	    c1--;
+	  }
+	  c0--;
+	  c1 -= 0x3f;
+	}
+	else
+	{
+	  c1 -= 0x9e;
+	}
+	*q++ = (c0 + 0x20) | 0x80;
+	*q++ = (c1 + 0x20) | 0x80;
+      }
+    }
+  }
+  else
+  {
+    int is_shift = 0;
+    q = new_str = (char*)malloc(strlen(str) + 1);
+    while (*p)
+    {
+      if (p[0] == '\033' && p[1] == '$' && (p[2] == '@' || p[2] == 'B'))
+      {
+        is_shift = 1;
+	p += 3;
+      }
+      else if (p[0] == '\033' && p[1] == '(' && (p[2] == 'B' || p[2] == 'J'))
+      {
+        is_shift = 0;
+        p += 3;
+      }
+      else if (is_shift)
+      {
+        *q++ = *p++ | 0x80;
+	if (*p)
+          *q++ = *p++ | 0x80;
+      }
+      else
+      {
+        *q++ = *p++;
+      }
+    }
+  }
+  *q = '\0';
+  str = new_str;
+#endif /* CHIMERA_JP */
+
   list = NULL;
   current = NULL;
 
@@ -967,6 +1067,9 @@
   gettimeofday (&Tv, &Tz);
   fprintf (stderr, "HTMLParse exit (%d.%d)\n", Tv.tv_sec, Tv.tv_usec);
 #endif
+#ifdef CHIMERA_JP
+  free(new_str);
+#endif /* CHIMERA_JP */
   return (list);
 }
 
diff -urN chimera-1.70p1/libhtmlw/Imakefile chimera-1.70p1-jp-01/libhtmlw/Imakefile
--- chimera-1.70p1/libhtmlw/Imakefile	Mon Mar 27 15:18:40 1995
+++ chimera-1.70p1-jp-01/libhtmlw/Imakefile	Wed May 28 02:44:34 1997
@@ -8,7 +8,8 @@
 OBJS    = HTML.o HTMLformat.o HTMLimages.o HTMLlists.o \
           HTMLparse.o HTMLwidgets.o HTML-PSformat.o DrawingArea.o
 
-EXTRA_DEFINES  = -DISINDEX_SUBMIT $(XRELEASE) -DFAKE_EXPOSE $(CEXTRA_DEFINES)
+EXTRA_DEFINES  = -DISINDEX_SUBMIT $(XRELEASE) -DFAKE_EXPOSE $(CEXTRA_DEFINES) \
+                 $(KANJI_DEFINES)
 EXTRA_INCLUDES = -I../mxw -I../common
 
 NormalLibraryTarget(htmlw, $(OBJS))
diff -urN chimera-1.70p1/options.h.dist chimera-1.70p1-jp-01/options.h.dist
--- chimera-1.70p1/options.h.dist	Mon May 26 06:44:05 1997
+++ chimera-1.70p1-jp-01/options.h.dist	Wed May 28 04:49:54 1997
@@ -7,7 +7,11 @@
  */
 
 #define PRINT_COMMAND "lpr -h -P%s"		/* command to pipe to print */
+#ifdef CHIMERA_JP
+#define USER_AGENT "Chimera/1.70p1-JP-01"	/* User-Agent field for HTTP */
+#else
 #define USER_AGENT "Chimera/1.70p1"		/* User-Agent field for HTTP */
+#endif
 #define EMAIL_COMMAND "mail %s"			/* pipe to command for mail */
 #define PATH CUTILDIR 				/* default program PATH */
 /*#define CHILD_STDERR "/dev/null"*/                /* stderr for children
diff -urN chimera-1.70p1/src/Imakefile chimera-1.70p1-jp-01/src/Imakefile
--- chimera-1.70p1/src/Imakefile	Mon May 26 06:44:05 1997
+++ chimera-1.70p1-jp-01/src/Imakefile	Wed May 28 02:44:35 1997
@@ -19,7 +19,8 @@
        md5.o auth.o lang.o stringdb.o inline.o widget.o convert.o \
        fallback.o
 
-DEFINES          = $(XRELEASE) $(CDEFINES) $(CSOCKS) $(CTERM) $(CEXTRA_DEFINES)
+DEFINES          = $(XRELEASE) $(CDEFINES) $(CSOCKS) $(CTERM) \
+                   $(CEXTRA_DEFINES) $(KANJI_DEFINES)
 INCLUDES         = -I../libhtmlw -I../mxw -I../ -I../xloadimage $(CTERMINC) \
                    -I../common
 EXTRA_LOAD_FLAGS = /* -static */
diff -urN chimera-1.70p1/src/main.c chimera-1.70p1-jp-01/src/main.c
--- chimera-1.70p1/src/main.c	Mon May 26 06:44:06 1997
+++ chimera-1.70p1-jp-01/src/main.c	Wed May 28 02:44:35 1997
@@ -53,6 +53,27 @@
 #include "stringdb.h"
 #include "widget.h"
 
+#ifdef CHIMERA_JP
+#include <X11/Xlocale.h>
+
+#ifdef SETLOCALE
+char* setlocale(int type, const char* new)
+{
+  static char locale[16] = "C";
+
+  if (new != NULL)
+    strcpy(locale, new);
+  return locale;
+}
+#endif /* SETLOCALE */
+
+#if XRELEASE==5 && !defined(sgi) && !defined(XIMP)
+#define EUC_LOCALE	"ja_JP.ujis"
+#else
+#define EUC_LOCALE	"ja_JP.EUC"
+#endif
+#endif /* CHIMERA_JP */
+
 /*
  * convenience routines.
  */
@@ -115,6 +136,10 @@
 #define offset(field) XtOffset(AppResources *, field)
 static XtResource       resource_list[] =
 {
+#ifdef CHIMERA_JP
+  { "locale", "xnlLanguage", XtRString, sizeof(char *),
+	offset(locale), XtRImmediate, EUC_LOCALE },
+#endif /* CHIMERA_JP */
   { "convertFiles", "Files", XtRString, sizeof(char *),
 	offset(convertFiles), XtRString, (XtPointer)CONVERT_FILES },
   { "homeURL", "URL", XtRString, sizeof(char *),
@@ -273,6 +298,11 @@
   /*
    * this is hiding in widget.c.
    */
+#ifdef CHIMERA_JP
+  if (!setlocale (LC_CTYPE, root.locale))
+    fprintf(stderr, "Can't setlocale to %s\n", root.locale);
+#endif /* CHIMERA_JP */
+
   CreateWidgets(&root);
 
   if (root.urldisplay != 0)
diff -urN chimera-1.70p1/src/widget.h chimera-1.70p1-jp-01/src/widget.h
--- chimera-1.70p1/src/widget.h	Mon May 26 06:44:07 1997
+++ chimera-1.70p1-jp-01/src/widget.h	Wed May 28 02:44:35 1997
@@ -25,6 +25,9 @@
 
 typedef struct _htmlroot
 {
+#ifdef CHIMERA_JP
+  char *locale;
+#endif /* CHIMERA_JP */
   /*
    * Public
    */