6e9294f
diff -up a2ps-4.14/config.h.in.euc a2ps-4.14/config.h.in
6e9294f
--- a2ps-4.14/config.h.in.euc	2007-12-29 04:28:05.000000000 +0100
6e9294f
+++ a2ps-4.14/config.h.in	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -24,6 +24,9 @@
6e9294f
 /* Define if TIOCGWINSZ requires sys/ioctl.h */
6e9294f
 #undef GWINSZ_IN_SYS_IOCTL
6e9294f
 
6e9294f
+/* Define if you want to support japanese  */
6e9294f
+#undef ENABLE_KANJI
6e9294f
+ 
6e9294f
 /* Define to 1 if you have the `alarm' function. */
6e9294f
 #undef HAVE_ALARM
6e9294f
 
6e9294f
diff -up a2ps-4.14/configure.euc a2ps-4.14/configure
6e9294f
--- a2ps-4.14/configure.euc	2008-04-27 10:39:24.000000000 +0200
6e9294f
+++ a2ps-4.14/configure	2008-04-27 10:41:39.000000000 +0200
6e9294f
@@ -1587,7 +1587,8 @@ Optional Packages:
6e9294f
   --with-medium=medium    specify the default medium (A4, Letter, Legal, etc.)
6e9294f
                           default=A4
6e9294f
   --with-encoding=enc     specify the default encoding (ascii, latin1,
6e9294f
-                          latin2... latin6, hp etc.) default=latin1
6e9294f
+                          latin2... latin6, euc-jp, hp etc.) default=latin1
6e9294f
+  --enable-kanji 	  support Japanese (default=yes)
6e9294f
 
6e9294f
 Some influential environment variables:
6e9294f
   CC          C compiler command
6e9294f
@@ -22521,7 +22522,7 @@ fi
6e9294f
 
6e9294f
 for ac_header in sys/time.h sys/stat.h sys/types.h sys/ioctl.h  \
6e9294f
  math.h string.h strings.h stdlib.h unistd.h stdarg.h pwd.h malloc.h \
6e9294f
- memory.h errno.h fcntl.h stdbool.h fnmatch.h
6e9294f
+ memory.h errno.h fcntl.h stdbool.h fnmatch.h iconv.h
6e9294f
 do
6e9294f
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
6e9294f
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
6e9294f
@@ -30947,6 +30948,22 @@ fi
6e9294f
 
6e9294f
 
6e9294f
 
6e9294f
+# Check whether --enable-kanji or --disable-kanji was given.
6e9294f
+if test "${enable_kanji+set}" = set; then
6e9294f
+  enableval="$enable_kanji"
6e9294f
+  SUPPORT_KANJI=$enableval
6e9294f
+else
6e9294f
+  SUPPORT_KANJI=yes
6e9294f
+fi
6e9294f
+
6e9294f
+if test "$SUPPORT_KANJI" = "yes"; then
6e9294f
+	cat >> confdefs.h <<\EOF
6e9294f
+#define ENABLE_KANJI 1
6e9294f
+EOF
6e9294f
+#	ENCODING=euc-jp
6e9294f
+fi
6e9294f
+
6e9294f
+
6e9294f
 ########################
6e9294f
 # Nice special printers
6e9294f
 ########################
6e9294f
diff -up a2ps-4.14/configure.in.euc a2ps-4.14/configure.in
6e9294f
--- a2ps-4.14/configure.in.euc	2008-04-27 10:39:24.000000000 +0200
6e9294f
+++ a2ps-4.14/configure.in	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -72,7 +72,7 @@ AC_HEADER_SYS_WAIT
6e9294f
 AC_HEADER_DIRENT
6e9294f
 AC_CHECK_HEADERS(sys/time.h sys/stat.h sys/types.h sys/ioctl.h  \
6e9294f
  math.h string.h strings.h stdlib.h unistd.h stdarg.h pwd.h malloc.h \
6e9294f
- memory.h errno.h fcntl.h stdbool.h fnmatch.h)
6e9294f
+ memory.h errno.h fcntl.h stdbool.h fnmatch.h iconv.h)
6e9294f
 
6e9294f
 ## --------------------- ##
6e9294f
 ## Checks for typedefs.  ##
6e9294f
@@ -276,11 +276,23 @@ AC_SUBST(MEDIUM)
6e9294f
 #
6e9294f
 AC_ARG_WITH(encoding,
6e9294f
 AC_HELP_STRING([--with-encoding=enc],
6e9294f
-               [specify the default encoding (ascii, latin1, latin2... latin6, hp etc.) [default=latin1]]),
6e9294f
+               [specify the default encoding (ascii, latin1, latin2... latin6, euc-jp, hp etc.) [default=latin1]]),
6e9294f
 ENCODING=$with_encoding,
6e9294f
 ENCODING=latin1)
6e9294f
 AC_SUBST(ENCODING)
6e9294f
 
6e9294f
+#
6e9294f
+# use libjcode
6e9294f
+#
6e9294f
+AC_ARG_ENABLE(kanji,
6e9294f
+	[  --enable-kanji	  support Japanese/kanji (default: yes)],
6e9294f
+			SUPPORT_KANJI=$enableval, SUPPORT_KANJI=yes)
6e9294f
+if test "$SUPPORT_KANJI" = "yes"; then
6e9294f
+	AC_DEFINE(ENABLE_KANJI)
6e9294f
+	dnl ENCODING=euc-jp
6e9294f
+fi
6e9294f
+
6e9294f
+
6e9294f
 ########################
6e9294f
 # Nice special printers
6e9294f
 ########################
6e9294f
diff -up a2ps-4.14/encoding/encoding.map.euc a2ps-4.14/encoding/encoding.map
6e9294f
--- a2ps-4.14/encoding/encoding.map.euc	2007-12-29 02:39:21.000000000 +0100
6e9294f
+++ a2ps-4.14/encoding/encoding.map	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -93,6 +93,12 @@ koi8r			koi8
6e9294f
 koi8			koi8
6e9294f
 koi			koi8
6e9294f
 
6e9294f
+euc-jp			euc-jp
6e9294f
+eucjp			euc-jp
6e9294f
+japanese		euc-jp
6e9294f
+ja			euc-jp
6e9294f
+jp			euc-jp
6e9294f
+
6e9294f
 ########################################################################
6e9294f
 # Some architectures specific char sets
6e9294f
 ########################################################################
6e9294f
diff -up /dev/null a2ps-4.14/encoding/euc-jp.edf
6e9294f
--- /dev/null	2008-04-27 11:55:27.307012118 +0200
6e9294f
+++ a2ps-4.14/encoding/euc-jp.edf	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -0,0 +1,109 @@
6e9294f
+# Description of the EUC-JP encoding
6e9294f
+# Copyright (c) 1988, 89, 90, 91, 92, 93 Miguel Santana
6e9294f
+# Copyright (c) 1995, 96, 97, 98 Akim Demaille, Miguel Santana
6e9294f
+#
6e9294f
+
6e9294f
+#
6e9294f
+# This file is part of a2ps.
6e9294f
+# 
6e9294f
+# This program is free software; you can redistribute it and/or modify
6e9294f
+# it under the terms of the GNU General Public License as published by
6e9294f
+# the Free Software Foundation; either version 2, or (at your option)
6e9294f
+# any later version.
6e9294f
+#
6e9294f
+# This program is distributed in the hope that it will be useful,
6e9294f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
6e9294f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6e9294f
+# GNU General Public License for more details.
6e9294f
+#
6e9294f
+# You should have received a copy of the GNU General Public License
6e9294f
+# along with this program; see the file COPYING.  If not, write to
6e9294f
+# the Free Software Foundation, 59 Temple Place - Suite 330,
6e9294f
+# Boston, MA 02111-1307, USA.
6e9294f
+#
6e9294f
+
6e9294f
+Name: EUC-JP
6e9294f
+
6e9294f
+# This text is reproduced by a courtesy of Roman Czyborra
6e9294f
+# http://czyborra.com/charsets/iso8859.html
6e9294f
+Documentation
6e9294f
+The EUC-JP character set, often simply referred to as Latin 1,
6e9294f
+covers most West European languages, such as French, Spanish, Catalan,
6e9294f
+Basque, Portuguese, Italian, Albanian, Rhaeto-Romanic, Dutch, German,
6e9294f
+Danish, Swedish, Norwegian, Finnish, Faroese, Icelandic, Irish,
6e9294f
+Scottish, and English, incidentally also Afrikaans and Swahili, thus
6e9294f
+in effect also the entire American continent, Australia and the
6e9294f
+southern two-thirds of Africa. The lack of the ligatures Dutch IJ,
6e9294f
+French OE and ,,German`` quotation marks is considered tolerable.
6e9294f
+
6e9294f
+The lack of the new C=-resembling Euro currency symbol U+20AC has
6e9294f
+opened the discussion of a new Latin0.
6e9294f
+EndDocumentation
6e9294f
+
6e9294f
+# If there is an unknown font requested, use Courier
6e9294f
+Default: Courier
6e9294f
+
6e9294f
+# Automatic spell checking :)
6e9294f
+Substitute: 	Times			Times-Roman
6e9294f
+Substitute: 	Helvetica-Italic	Helvetica-Oblique
6e9294f
+Substitute: 	Helvetica-BoldItalic	Helvetica-BoldOblique
6e9294f
+
6e9294f
+
6e9294f
+# SlantFont for Japanese Italic Kanji font
6e9294f
+#		new font			source font		value
6e9294f
+SlantFont:	Ryumin-Light-EUC-H-Italic	Ryumin-Light-EUC-H	0.2
6e9294f
+SlantFont:	GothicBBB-Medium-EUC-H-Italic	GothicBBB-Medium-EUC-H	0.2
6e9294f
+
6e9294f
+# Compose font for japanese EUC code
6e9294f
+#		target font		additional font			width	size rate
6e9294f
+DefaultComposite:			Ryumin-Light-EUC-H		1.0	1.1
6e9294f
+
6e9294f
+# 1:2 fixed
6e9294f
+#DefaultComposite:			Ryumin-Light-EUC-H		1.0	0.8333
6e9294f
+
6e9294f
+# 1:1 fixed
6e9294f
+#DefaultComposite:			Ryumin-Light-EUC-H		1.0	1.6666
6e9294f
+
6e9294f
+Composite:	Helvetica		GothicBBB-Medium-EUC-H		1.0	1.1
6e9294f
+Composite:	Helvetica-Oblique	GothicBBB-Medium-EUC-H-Italic	1.0 	1.1
6e9294f
+Composite:	Helvetica-Bold		GothicBBB-Medium-EUC-H  	1.0 	1.1
6e9294f
+Composite:	Helvetica-BoldOblique	GothicBBB-Medium-EUC-H-Italic	1.0	1.1
6e9294f
+
6e9294f
+Composite:	Courier-Oblique		Ryumin-Light-EUC-H-Italic	1.0	1.1
6e9294f
+Composite:	Courier-Bold		GothicBBB-Medium-EUC-H		1.0	1.1
6e9294f
+Composite:	Courier-BoldOblique	GothicBBB-Medium-EUC-H-Italic	1.0	1.1
6e9294f
+Composite:	Times-Bold		GothicBBB-Medium-EUC-H		1.0	1.1
6e9294f
+
6e9294f
+Vector:
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+space exclam quotedbl numbersign dollar percent ampersand quoteright
6e9294f
+parenleft parenright asterisk plus comma minus period slash
6e9294f
+zero one two three four five six seven
6e9294f
+eight nine colon semicolon less equal greater question
6e9294f
+at A B C D E F G
6e9294f
+H I J K L M N O
6e9294f
+P Q R S T U V W
6e9294f
+X Y Z bracketleft backslash bracketright asciicircum underscore
6e9294f
+quoteleft a b c d e f g
6e9294f
+h i j k l m n o
6e9294f
+p q r s t u v w
6e9294f
+x y z braceleft bar braceright asciitilde .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6e9294f
+space exclamdown cent sterling currency yen brokenbar section
6e9294f
+dieresis copyright ordfeminine guillemotleft logicalnot hyphen registered macron
6e9294f
+degree plusminus twosuperior threesuperior acute mu paragraph bullet
6e9294f
+cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown
6e9294f
+Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla
6e9294f
+Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
6e9294f
+Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply
6e9294f
+Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls
6e9294f
+agrave aacute acircumflex atilde adieresis aring ae ccedilla
6e9294f
+egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis
6e9294f
+eth ntilde ograve oacute ocircumflex otilde odieresis divide
6e9294f
+oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
6e9294f
diff -up a2ps-4.14/encoding/Makefile.am.euc a2ps-4.14/encoding/Makefile.am
6e9294f
--- a2ps-4.14/encoding/Makefile.am.euc	2007-12-29 02:39:27.000000000 +0100
6e9294f
+++ a2ps-4.14/encoding/Makefile.am	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -16,7 +16,7 @@ major_encodings = ascii.edf iso1.edf
6e9294f
 minor_encodings = \
6e9294f
 ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
6e9294f
 iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
6e9294f
-iso15.edf koi8.edf ms-cp1251.edf
6e9294f
+iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
6e9294f
 
6e9294f
 if EXTENSIONS
6e9294f
 encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
6e9294f
diff -up a2ps-4.14/encoding/Makefile.in.euc a2ps-4.14/encoding/Makefile.in
6e9294f
--- a2ps-4.14/encoding/Makefile.in.euc	2007-12-29 04:28:07.000000000 +0100
6e9294f
+++ a2ps-4.14/encoding/Makefile.in	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -270,7 +270,7 @@ major_encodings = ascii.edf iso1.edf
6e9294f
 minor_encodings = \
6e9294f
 ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
6e9294f
 iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
6e9294f
-iso15.edf koi8.edf ms-cp1251.edf
6e9294f
+iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
6e9294f
 
6e9294f
 @EXTENSIONS_FALSE@encodings_DATA = encoding.map $(major_encodings)
6e9294f
 @EXTENSIONS_TRUE@encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
6e9294f
diff -up a2ps-4.14/lib/encoding.c.euc a2ps-4.14/lib/encoding.c
6e9294f
--- a2ps-4.14/lib/encoding.c.euc	2007-12-29 02:37:54.000000000 +0100
6e9294f
+++ a2ps-4.14/lib/encoding.c	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -37,6 +37,9 @@
6e9294f
 #include "document.h"
6e9294f
 #include "quotearg.h"
6e9294f
 #include "strverscmp.h"
6e9294f
+#ifdef ENABLE_KANJI
6e9294f
+int use_jcode = false;
6e9294f
+#endif
6e9294f
 
6e9294f
 /* Suffix of the Encoding Description Files */
6e9294f
 #define EDF_SUFFIX ".edf"
6e9294f
@@ -389,15 +392,25 @@ font_entry_set_used (struct hash_table_s
6e9294f
  * Association of suffixes rules, and corresponding style sheet
6e9294f
  * (The hashing is upon `alias')
6e9294f
  */
6e9294f
+struct slantfont_info {
6e9294f
+  char * name;
6e9294f
+  char * src;
6e9294f
+  float raito;
6e9294f
+};
6e9294f
+
6e9294f
 struct encoding {
6e9294f
   char * key;			/* e.g. latin1			*/
6e9294f
   char * name;			/* e.g. ISO Latin 1		*/
6e9294f
+  int    composite_flag;		/* flag for composite font	*/
6e9294f
   uchar * documentation;		/* Useful pieces of text	*/
6e9294f
 
6e9294f
   char * default_font;		/* When a font can't be used
6e9294f
 				   define the font to use	*/
6e9294f
   struct pair_htable * substitutes;	/* e.g. in latin2, don't use
6e9294f
 					 * Courier, but Courier-Ogonki	*/
6e9294f
+  struct pair_htable * composite;
6e9294f
+
6e9294f
+  struct slantfont_info     slantfont[NB_FACES];
6e9294f
 
6e9294f
   char * vector[256];	/* Define the char set			*/
6e9294f
   struct darray * font_names_used;
6e9294f
@@ -407,6 +420,9 @@ struct encoding {
6e9294f
   struct hash_table_s * fonts;	/* Contains cells that are
6e9294f
 				 * 1. name of font, 2. int wx[256] 	*/
6e9294f
   unsigned int * faces_wx[NB_FACES];
6e9294f
+
6e9294f
+  unsigned int   composite_wx[NB_FACES];     /* fixed length font width*/
6e9294f
+  float          composite_raito[NB_FACES];  /* size raito of additonal and orinal font */
6e9294f
 };
6e9294f
 
6e9294f
 /*
6e9294f
@@ -423,9 +439,12 @@ encoding_new (const char * key)
6e9294f
   res->name = NULL;
6e9294f
   res->default_font = NULL;
6e9294f
   res->documentation = NULL;
6e9294f
+  res->composite_flag = false;
6e9294f
 
6e9294f
   /* Vector will be set by setup */
6e9294f
   res->substitutes = pair_table_new ();
6e9294f
+  res->composite = pair_table_new ();
6e9294f
+  res->slantfont[0].name = NULL;
6e9294f
   res->font_names_used = da_new ("List of font names", 10,
6e9294f
 				 da_linear, 10,
6e9294f
 				 (da_print_func_t) da_str_print,
6e9294f
@@ -471,6 +490,34 @@ encoding_add_font_substitute (struct enc
6e9294f
 }
6e9294f
 
6e9294f
 /*
6e9294f
+ * Add a composite font in the current encoding
6e9294f
+ */
6e9294f
+static void
6e9294f
+encoding_add_composite_font (struct encoding * encoding,
6e9294f
+			      const char * orig, const char * subs,
6e9294f
+			      int wx, float raito)
6e9294f
+{
6e9294f
+  encoding->composite_flag = true;
6e9294f
+  pair_add2 (encoding->composite, orig, subs, wx, raito);
6e9294f
+}
6e9294f
+
6e9294f
+/*
6e9294f
+ * Add a composite font in the current encoding
6e9294f
+ */
6e9294f
+static void
6e9294f
+encoding_add_slant_font (struct encoding * encoding,
6e9294f
+			 const char * new, const char * src,
6e9294f
+			 float raito)
6e9294f
+{
6e9294f
+  static num =  0;
6e9294f
+  encoding->slantfont[num].name = strdup(new);
6e9294f
+  encoding->slantfont[num].src  = strdup(src);
6e9294f
+  encoding->slantfont[num].raito = raito;
6e9294f
+  encoding->slantfont[num+1].name = NULL;
6e9294f
+  num++;
6e9294f
+}
6e9294f
+
6e9294f
+/*
6e9294f
  * When FONT_NAME is used with ENCODING, return the
6e9294f
  * real font name to use (e.g., in latin2, Courier-Ogonki
6e9294f
  * should be returned when asked for Courier).
6e9294f
@@ -514,6 +561,77 @@ encoding_resolve_font_substitute (struct
6e9294f
     }
6e9294f
 
6e9294f
   message (msg_enc,
6e9294f
+	   (stderr, "In encoding %s, composite font for %s is resolved as %s\n",
6e9294f
+	    encoding->key, font_name, res));
6e9294f
+  return res;
6e9294f
+}
6e9294f
+
6e9294f
+/*
6e9294f
+ * Get composite font size and raito
6e9294f
+ */
6e9294f
+static int
6e9294f
+composite_font_info_get_wx(struct a2ps_job * job,
6e9294f
+			   struct encoding * encoding,
6e9294f
+			   const char * font_list)
6e9294f
+{
6e9294f
+  int wx= -1;
6e9294f
+  char * font_list_copy;
6e9294f
+  char * font_name;
6e9294f
+  astrcpy (font_list_copy, font_list);
6e9294f
+  font_name = strtok (font_list_copy, ",<>;");
6e9294f
+
6e9294f
+  wx = pair_get_wx (encoding->composite, font_name);
6e9294f
+  if (wx<0)
6e9294f
+      wx = pair_get_wx (encoding->composite, "default_composite__");
6e9294f
+
6e9294f
+  return wx;
6e9294f
+}
6e9294f
+
6e9294f
+static float
6e9294f
+composite_font_info_get_raito(struct a2ps_job * job,
6e9294f
+			      struct encoding * encoding,
6e9294f
+			      const char * font_list)
6e9294f
+{
6e9294f
+  float raito= -1;
6e9294f
+  char * font_list_copy;
6e9294f
+  char * font_name;
6e9294f
+
6e9294f
+  astrcpy (font_list_copy, font_list);
6e9294f
+  font_name = strtok (font_list_copy, ",<>;");
6e9294f
+
6e9294f
+  raito = pair_get_raito (encoding->composite, font_name);
6e9294f
+  if (raito<0)
6e9294f
+      raito = pair_get_raito (encoding->composite, "default_composite__");
6e9294f
+  return raito;
6e9294f
+}
6e9294f
+
6e9294f
+const char *
6e9294f
+encoding_resolve_composite_font (struct a2ps_job * job,
6e9294f
+				  struct encoding * encoding,
6e9294f
+				  const char * font_list)
6e9294f
+{
6e9294f
+  const char * res = NULL;
6e9294f
+  char * font_list_copy;
6e9294f
+  char * font_name;
6e9294f
+
6e9294f
+  astrcpy (font_list_copy, font_list);
6e9294f
+  font_name = strtok (font_list_copy, ",<>;");
6e9294f
+
6e9294f
+  /* Find if there is a substitute for that font */
6e9294f
+  res = pair_get (encoding->composite, font_name);
6e9294f
+
6e9294f
+  /* We've found nothing interesting.  Last chance is the default
6e9294f
+   * font */
6e9294f
+  if (!res)
6e9294f
+    {
6e9294f
+      res = pair_get (encoding->composite, "default_composite__");
6e9294f
+
6e9294f
+      if (!res)
6e9294f
+	error (1, 0, "Cannot find font %s, nor any composite font",
6e9294f
+	       font_name);
6e9294f
+    }
6e9294f
+  
6e9294f
+  message (msg_enc,
6e9294f
 	   (stderr, "In encoding %s, font %s is resolved as %s\n",
6e9294f
 	    encoding->key, font_name, res));
6e9294f
   return res;
6e9294f
@@ -585,6 +703,12 @@ load_encoding_description_file (a2ps_job
6e9294f
 	{
6e9294f
 	  token2 = GET_TOKEN (NULL);
6e9294f
 	  CHECK_TOKEN ();
6e9294f
+#ifdef ENABLE_KANJI
6e9294f
+	  if( strcmp(token2, "EUC-JP")== 0)
6e9294f
+	    use_jcode = true;
6e9294f
+	  else 
6e9294f
+	    use_jcode = false;
6e9294f
+#endif
6e9294f
 	  encoding->name = xstrdup (token2);
6e9294f
 	}
6e9294f
       else if (strequ (token, "Default:"))
6e9294f
@@ -633,6 +757,66 @@ load_encoding_description_file (a2ps_job
6e9294f
 	  subs = token2;
6e9294f
 	  encoding_add_font_substitute (encoding, orig, subs);
6e9294f
 	}
6e9294f
+      else if (strequ (token, "DefaultComposite:"))
6e9294f
+	{
6e9294f
+	  char * orig, * subs;
6e9294f
+	  int wx;
6e9294f
+	  float raito;
6e9294f
+
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  subs = token2;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  wx = (int)atof(token2)*1000;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  raito = atof(token2);
6e9294f
+	  encoding_add_composite_font(encoding, "default_composite__",
6e9294f
+				      subs, wx, raito);
6e9294f
+	}
6e9294f
+      else if (strequ (token, "Composite:"))
6e9294f
+	{
6e9294f
+	  char * orig, * subs;
6e9294f
+	  int wx;
6e9294f
+	  float raito;
6e9294f
+
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  orig = token2;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  subs = token2;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  wx = (int)atof(token2)*1000;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  raito = atof(token2);
6e9294f
+	  encoding_add_composite_font(encoding, orig, subs, wx, raito);
6e9294f
+	}
6e9294f
+      else if (strequ (token, "SlantFont:"))
6e9294f
+	{
6e9294f
+	  char * new, * src;
6e9294f
+	  float raito;
6e9294f
+	  unsigned int num;
6e9294f
+
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  new = token2;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  src = token2;
6e9294f
+	  token2 = GET_TOKEN (NULL);
6e9294f
+	  CHECK_TOKEN ();
6e9294f
+	  raito = atof(token2);
6e9294f
+	  for (num = 0 ; encoding->slantfont[num].name ; num ++ );
6e9294f
+	  if (num > sizeof encoding->slantfont - 1){
6e9294f
+	      error_at_line (1, 0, fname, firstline,
6e9294f
+			   _("too many slant font: `%s'"), new);
6e9294f
+	  }
6e9294f
+	  encoding_add_slant_font(encoding, new, src, raito);
6e9294f
+	}
6e9294f
       else
6e9294f
         error_at_line (1, 0, fname, firstline,
6e9294f
                        _("invalid option `%s'"), quotearg (token));
6e9294f
@@ -754,6 +938,15 @@ encoding_char_exists (struct encoding * 
6e9294f
 }
6e9294f
 
6e9294f
 /*
6e9294f
+ * Return the flag of composite flag
6e9294f
+ */
6e9294f
+int
6e9294f
+encoding_get_composite_flag (struct encoding * enc)
6e9294f
+{
6e9294f
+  return enc->composite_flag;
6e9294f
+}
6e9294f
+
6e9294f
+/*
6e9294f
  * Prepare the environment (a dictionary) for the support
6e9294f
  * of ENCODING, dump it into STREAM.
6e9294f
  *
6e9294f
@@ -766,9 +959,11 @@ dump_encoding_setup (FILE * stream,
6e9294f
 		     struct encoding * encoding)
6e9294f
 {
6e9294f
   size_t i, nb;
6e9294f
+  size_t ns;
6e9294f
   const char * real_font_name;		/* After subsitution	*/
6e9294f
   char ** font_names = (char **) encoding->font_names_used->content;
6e9294f
 
6e9294f
+
6e9294f
   /* How many fonts are there? */
6e9294f
   da_qsort (encoding->font_names_used);
6e9294f
   da_unique (encoding->font_names_used, (da_map_func_t) free);
6e9294f
@@ -787,15 +982,46 @@ dump_encoding_setup (FILE * stream,
6e9294f
    * in the current ENCODING	*/
6e9294f
   nb = encoding->font_names_used->len;
6e9294f
 
6e9294f
+  /* The number of slant fonts */
6e9294f
+  for (i= 0, ns=0 ; encoding->slantfont[i].name ; i++ )
6e9294f
+      ns++;
6e9294f
+
6e9294f
   /* Create the dictionary and fill it */
6e9294f
   fprintf (stream, "%% Dictionary for %s support\n",
6e9294f
 	  encoding->name);
6e9294f
-  fprintf (stream, "/%sdict %d dict begin\n", encoding->key, nb);
6e9294f
+  fprintf (stream, "/%sdict %d dict begin\n", encoding->key,
6e9294f
+	   (encoding->composite_flag == true)? nb+nb+ns:nb+ns);
6e9294f
   for (i = 0 ; i < nb ; i++)
6e9294f
     fprintf (stream, "  /f%s %sEncoding /%s reencode_font\n",
6e9294f
 	     font_names [i],
6e9294f
 	     encoding->name,
6e9294f
 	     encoding_resolve_font_substitute (job, encoding, font_names [i]));
6e9294f
+
6e9294f
+  /* Slant font setting */
6e9294f
+  for (i = 0 ; encoding->slantfont[i].name ; i++ )
6e9294f
+    fprintf (stream, "  /%s /%s %f slantfont  definefont pop\n",
6e9294f
+	     encoding->slantfont[i].name,
6e9294f
+	     encoding->slantfont[i].src,
6e9294f
+	     encoding->slantfont[i].raito);
6e9294f
+
6e9294f
+  /*
6e9294f
+   * Composite font setting.
6e9294f
+   * If kanji font size is larger than alphabet character, 
6e9294f
+   * set base font size to kanji charactor size.
6e9294f
+   */
6e9294f
+  if (encoding->composite_flag == true) {
6e9294f
+    for (i = 0 ; i < nb ; i++)
6e9294f
+      fprintf (stream, "  /f%s /f%s /%s %f %f false  compositefont "
6e9294f
+	               "%f scalefont def\n",
6e9294f
+	       font_names [i],
6e9294f
+	       font_names [i],
6e9294f
+	       encoding_resolve_composite_font (job, encoding, font_names [i]),
6e9294f
+	       encoding->composite_raito[i],
6e9294f
+	       (encoding->composite_raito[i] > 1.0)?
6e9294f
+	       0: (1-encoding->composite_raito[i])/2.0,
6e9294f
+	       (encoding->composite_raito[i] > 1.0)?
6e9294f
+	       1.0/encoding->composite_raito[i]: 1.0 );
6e9294f
+  }
6e9294f
   fputs ("currentdict end def\n", stream);
6e9294f
 }
6e9294f
 
6e9294f
@@ -939,6 +1165,22 @@ encoding_build_faces_wx (a2ps_job * job,
6e9294f
 				   true_font_name,
6e9294f
 				   encoding->vector,
6e9294f
 				   encoding->faces_wx [face]);
6e9294f
+
6e9294f
+      if (encoding->composite_flag)
6e9294f
+	{
6e9294f
+	  encoding->composite_raito[i] =
6e9294f
+	    composite_font_info_get_raito(job, encoding, 
6e9294f
+					  job->face_eo_font [face]);
6e9294f
+
6e9294f
+	  encoding->composite_wx[i] =
6e9294f
+	    composite_font_info_get_wx(job, encoding, 
6e9294f
+				       job->face_eo_font [face]);
6e9294f
+
6e9294f
+	  /* If kanji font size is larger than alphabet character, 
6e9294f
+	     fit kanji charactor size to base font size */
6e9294f
+	  if (encoding->composite_raito[i] < 1.0)
6e9294f
+	      encoding->composite_wx[i] *= encoding->composite_raito[i]; 
6e9294f
+	}
6e9294f
     }
6e9294f
 }
6e9294f
 
6e9294f
@@ -1073,6 +1315,13 @@ char_WX (a2ps_job * job, uchar c)
6e9294f
   return 0;	/* For -Wall */
6e9294f
 }
6e9294f
 
6e9294f
+unsigned int
6e9294f
+char_composite_WX (a2ps_job * job, uchar c)
6e9294f
+{
6e9294f
+  return (job->encoding->composite_wx[job->status->face]/
6e9294f
+	  job->encoding->composite_raito[job->status->face]);
6e9294f
+}
6e9294f
+
6e9294f
 /*
6e9294f
  *	Returns the WX of a string (including M- and ^)
6e9294f
  */
6e9294f
diff -up a2ps-4.14/lib/encoding.h.euc a2ps-4.14/lib/encoding.h
6e9294f
--- a2ps-4.14/lib/encoding.h.euc	2007-12-29 02:58:17.000000000 +0100
6e9294f
+++ a2ps-4.14/lib/encoding.h	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -43,6 +43,7 @@ struct a2ps_job;	/* Declared in jobs.h w
6e9294f
  */
6e9294f
 unsigned int char_WX PARAMS ((struct a2ps_job * job, uchar c));
6e9294f
 unsigned int string_WX PARAMS ((struct a2ps_job * job, uchar * string));
6e9294f
+unsigned int char_composite_WX PARAMS ((struct a2ps_job * job, uchar c));
6e9294f
 
6e9294f
 
6e9294f
 /************************************************************************/
6e9294f
@@ -56,6 +57,7 @@ void encoding_self_print PARAMS ((struct
6e9294f
 					FILE * stream));
6e9294f
 int encoding_char_exists PARAMS ((struct encoding * enc,
6e9294f
 					enum face_e face, uchar c));
6e9294f
+int encoding_get_composite_flag (struct encoding * enc);
6e9294f
 struct encoding *
6e9294f
 get_encoding_by_alias PARAMS ((struct a2ps_job * job, 
6e9294f
 			       char *string));
6e9294f
@@ -71,6 +73,12 @@ const char * encoding_resolve_font_subst
6e9294f
 		 struct encoding * encoding,
6e9294f
 		 const char * font_name));
6e9294f
 
6e9294f
+
6e9294f
+const char * encoding_resolve_composite_font
6e9294f
+	PARAMS ((struct a2ps_job * job,
6e9294f
+		 struct encoding * encoding,
6e9294f
+		 const char * font_name));
6e9294f
+
6e9294f
 /*
6e9294f
  * Have a struct encoding determine the faces_wx
6e9294f
  */
6e9294f
diff -up a2ps-4.14/lib/pair_ht.c.euc a2ps-4.14/lib/pair_ht.c
6e9294f
--- a2ps-4.14/lib/pair_ht.c.euc	2007-12-29 02:58:21.000000000 +0100
6e9294f
+++ a2ps-4.14/lib/pair_ht.c	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -49,6 +49,8 @@ struct pair
6e9294f
 {
6e9294f
   char * key;
6e9294f
   char * value;
6e9294f
+  float  raito;
6e9294f
+  int    wx;
6e9294f
 };
6e9294f
 
6e9294f
 /*
6e9294f
@@ -165,6 +167,37 @@ pair_add (struct hash_table_s * table,
6e9294f
 }
6e9294f
 
6e9294f
 /*
6e9294f
+ *  Add a pair, with your own allocation for them.
6e9294f
+ * It KEY is yet used, override its value with VALUE
6e9294f
+ */
6e9294f
+void
6e9294f
+pair_add2 (struct hash_table_s * table,
6e9294f
+	  const char * key, const char * value, int wx, float raito)
6e9294f
+{
6e9294f
+  struct pair * item, token;
6e9294f
+  
6e9294f
+  token.key = (char *) key;
6e9294f
+  item = (struct pair *) hash_find_item (table, &token);
6e9294f
+
6e9294f
+  if (item) {
6e9294f
+    if (item->value)
6e9294f
+      free (item->value);
6e9294f
+  } else {
6e9294f
+    item = XMALLOC (struct pair, 1);
6e9294f
+    item->key = xstrdup(key);
6e9294f
+    item->wx    = wx;
6e9294f
+    item->raito = raito;
6e9294f
+  }
6e9294f
+  
6e9294f
+  if (value)
6e9294f
+    item->value = xstrdup (value);
6e9294f
+  else
6e9294f
+    item->value = NULL;
6e9294f
+
6e9294f
+  hash_insert (table, item);
6e9294f
+}
6e9294f
+
6e9294f
+/*
6e9294f
  * Remove a pair and free it.
6e9294f
  * It KEY is yet used, override its value with VALUE
6e9294f
  */
6e9294f
@@ -201,6 +234,34 @@ pair_get (struct hash_table_s * table, c
6e9294f
     return NULL;
6e9294f
 }
6e9294f
 
6e9294f
+int
6e9294f
+pair_get_wx (struct hash_table_s * table, const char * key)
6e9294f
+{
6e9294f
+  struct pair * item, token;
6e9294f
+  
6e9294f
+  token.key = (char *) key;
6e9294f
+  item = (struct pair *) hash_find_item (table, &token);
6e9294f
+
6e9294f
+  if (item)
6e9294f
+    return item->wx;
6e9294f
+  else
6e9294f
+    return -1;
6e9294f
+}
6e9294f
+
6e9294f
+float
6e9294f
+pair_get_raito (struct hash_table_s * table, const char * key)
6e9294f
+{
6e9294f
+  struct pair * item, token;
6e9294f
+  
6e9294f
+  token.key = (char *) key;
6e9294f
+  item = (struct pair *) hash_find_item (table, &token);
6e9294f
+
6e9294f
+  if (item)
6e9294f
+    return item->raito;
6e9294f
+  else
6e9294f
+    return -1;
6e9294f
+}
6e9294f
+
6e9294f
 /*
6e9294f
  * Return the content of the hash table, ordered
6e9294f
  */
6e9294f
diff -up a2ps-4.14/lib/pair_ht.h.euc a2ps-4.14/lib/pair_ht.h
6e9294f
--- a2ps-4.14/lib/pair_ht.h.euc	2007-12-29 02:58:21.000000000 +0100
6e9294f
+++ a2ps-4.14/lib/pair_ht.h	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -56,6 +56,10 @@ void pair_table_free PARAMS ((struct pai
6e9294f
 void pair_add PARAMS ((struct pair_htable * table, 
6e9294f
 		       const char * key, const char * value));
6e9294f
 
6e9294f
+void pair_add2 PARAMS ((struct pair_htable * table, 
6e9294f
+		       const char * key, const char * value,
6e9294f
+			int wx, float raito));
6e9294f
+
6e9294f
 /*
6e9294f
  * The key and value of the matching item  will be free'd
6e9294f
  * (No problem if KEY matches nothing)
6e9294f
@@ -68,6 +72,10 @@ void pair_delete PARAMS ((struct pair_ht
6e9294f
  */
6e9294f
 char * pair_get PARAMS ((struct pair_htable * table,
6e9294f
 			 const char * key));
6e9294f
+int    pair_get_wx PARAMS ((struct pair_htable * table,
6e9294f
+			    const char * key));
6e9294f
+float  pair_get_raito PARAMS ((struct pair_htable * table,
6e9294f
+			       const char * key));
6e9294f
 
6e9294f
 void pair_table_list_short PARAMS ((struct pair_htable * table,
6e9294f
 				    FILE * stream));
6e9294f
diff -up a2ps-4.14/lib/psgen.c.euc a2ps-4.14/lib/psgen.c
6e9294f
--- a2ps-4.14/lib/psgen.c.euc	2007-12-29 02:58:22.000000000 +0100
6e9294f
+++ a2ps-4.14/lib/psgen.c	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -875,6 +875,7 @@ ps_print_char (a2ps_job * job, int c, en
6e9294f
   print:
6e9294f
   default:
6e9294f
     {
6e9294f
+      static mb_flag= 0;
6e9294f
       uchar buf[256];
6e9294f
       int nchars;
6e9294f
       *buf = '\0';
6e9294f
@@ -889,6 +890,29 @@ ps_print_char (a2ps_job * job, int c, en
6e9294f
     job->status->face_declared = false;
6e9294f
   }
6e9294f
 
6e9294f
+  if (c > 127 && encoding_get_composite_flag (job->encoding) &&
6e9294f
+      job->status->face != Symbol) {
6e9294f
+    if (mb_flag) {
6e9294f
+        nchars = ps_escape_char (job, mb_flag, buf) + 
6e9294f
+	         ps_escape_char (job, c, buf);
6e9294f
+	job->status->wx += char_composite_WX(job, c);
6e9294f
+	job->status->column += nchars;
6e9294f
+	if (line_full) {
6e9294f
+	    if (job->folding) {
6e9294f
+	        fold_line (job, new_face);
6e9294f
+		job->status->column = nchars*2;
6e9294f
+		job->status->wx = char_composite_WX(job, c);
6e9294f
+	    } else {
6e9294f
+	      job->status->is_in_cut = true;
6e9294f
+	      return;
6e9294f
+	    }
6e9294f
+	}
6e9294f
+	mb_flag = 0;
6e9294f
+    } else {
6e9294f
+        mb_flag = c;
6e9294f
+	return;
6e9294f
+    }
6e9294f
+  } else {
6e9294f
       nchars = ps_escape_char (job, c, buf);
6e9294f
       job->status->wx += char_WX (job, c);
6e9294f
       job->status->column += nchars;
6e9294f
@@ -902,8 +926,9 @@ ps_print_char (a2ps_job * job, int c, en
6e9294f
 	  return;
6e9294f
 	}
6e9294f
       }
6e9294f
+  }
6e9294f
       output (jdiv, "%s", buf);
6e9294f
-      job->status->chars++;
6e9294f
+      job->status->chars+=nchars;
6e9294f
     }
6e9294f
     break;
6e9294f
   }
6e9294f
diff -up a2ps-4.14/ps/base.ps.euc a2ps-4.14/ps/base.ps
6e9294f
--- a2ps-4.14/ps/base.ps.euc	2007-12-29 02:58:26.000000000 +0100
6e9294f
+++ a2ps-4.14/ps/base.ps	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -153,7 +153,11 @@
6e9294f
 % Return the y size of the current font
6e9294f
 % - => fontsize
6e9294f
 /currentfontsize {
6e9294f
-  currentfont /FontMatrix get 3 get 1000 mul
6e9294f
+  currentfont /FontType get 0 eq {
6e9294f
+    currentfont /FontMatrix get 3 get
6e9294f
+  }{
6e9294f
+    currentfont /FontMatrix get 3 get 1000 mul
6e9294f
+  } ifelse
6e9294f
 } bind def
6e9294f
 
6e9294f
 % reencode the font
6e9294f
@@ -200,6 +204,144 @@
6e9294f
   end 
6e9294f
 } bind def
6e9294f
 
6e9294f
+% composite fonts for ASCII-EUC mixed string
6e9294f
+% Version 1.2 1/31/1990
6e9294f
+% Orignal Ken'ichi HANDA (handa@etl.go.jp)
6e9294f
+% Modified Norio Katayama (katayama@rd.nacsis.ac.jp),1998
6e9294f
+% Extend & Fix Koji Nakamaru (maru@on.cs.keio.ac.jp), 1999
6e9294f
+% Anyone can freely copy, modify, distribute this program.
6e9294f
+
6e9294f
+/copyfont {	% font-dic extra-entry-count  copyfont  font-dic
6e9294f
+	1 index maxlength add dict begin
6e9294f
+	{	1 index /FID ne 2 index /UniqueID ne and
6e9294f
+		{def} {pop pop} ifelse
6e9294f
+	} forall
6e9294f
+	currentdict
6e9294f
+	end
6e9294f
+} bind def
6e9294f
+
6e9294f
+/compositefont { % ASCIIFontName EUCFontName RomanScale RomanOffset Rot(T/F) compositefont font
6e9294f
+    /RomanRotation exch def
6e9294f
+    /RomanOffset exch def
6e9294f
+    /RomanScale exch def
6e9294f
+    userdict /fixeucfont_dict known not {
6e9294f
+	userdict begin
6e9294f
+	    /fixeucfont_dict 2 dict begin
6e9294f
+		/UpperByteEncoding [
6e9294f
+		    16#00 1 16#20 { pop 0 } for
6e9294f
+		    16#21 1 16#28 { 16#20 sub } for
6e9294f
+		    16#29 1 16#2F { pop 0 } for
6e9294f
+		    16#30 1 16#74 { 16#27 sub } for
6e9294f
+		    16#75 1 16#FF { pop 0 } for
6e9294f
+		] def
6e9294f
+	        /LowerByteEncoding [
6e9294f
+		    16#00 1 16#A0 { pop /.notdef } for
6e9294f
+		    16#A1 1 16#FE { 16#80 sub 16 2 string cvrs
6e9294f
+				    (cXX) dup 1 4 -1 roll
6e9294f
+				    putinterval cvn } for
6e9294f
+		    /.notdef
6e9294f
+		] def
6e9294f
+		currentdict
6e9294f
+	    end def
6e9294f
+	end
6e9294f
+    } if
6e9294f
+    findfont dup /FontType get 0 eq {
6e9294f
+	14 dict begin
6e9294f
+	    %
6e9294f
+	    % 7+8 bit EUC font
6e9294f
+	    %
6e9294f
+	    12 dict begin
6e9294f
+		/EUCFont exch def
6e9294f
+		/FontInfo (7+8 bit EUC font) readonly def
6e9294f
+		/PaintType 0 def
6e9294f
+		/FontType 0 def
6e9294f
+		/FontMatrix matrix def
6e9294f
+		% /FontName
6e9294f
+		/Encoding fixeucfont_dict /UpperByteEncoding get def
6e9294f
+		/FMapType 2 def
6e9294f
+		EUCFont /WMode known
6e9294f
+		{ EUCFont /WMode get /WMode exch def }
6e9294f
+		{ /WMode 0 def } ifelse
6e9294f
+		/FDepVector [
6e9294f
+		    EUCFont /FDepVector get 0 get
6e9294f
+		    [ 16#21 1 16#28 {} for 16#30 1 16#74 {} for ]
6e9294f
+		    {
6e9294f
+			13 dict begin
6e9294f
+			    /EUCFont EUCFont def
6e9294f
+			    /UpperByte exch 16#80 add def	
6e9294f
+			    % /FontName
6e9294f
+			    /FontInfo (EUC lower byte font) readonly def
6e9294f
+			    /PaintType 0 def
6e9294f
+			    /FontType 3 def
6e9294f
+			    /FontMatrix matrix def
6e9294f
+			    /FontBBox {0 0 0 0} def
6e9294f
+			    /Encoding
6e9294f
+				fixeucfont_dict /LowerByteEncoding get def
6e9294f
+			    % /UniqueID
6e9294f
+			    % /WMode
6e9294f
+			    /BuildChar {
6e9294f
+				gsave
6e9294f
+				exch dup /EUCFont get setfont
6e9294f
+				/UpperByte get
6e9294f
+				2 string
6e9294f
+				dup 0 4 -1 roll put
6e9294f
+				dup 1 4 -1 roll put
6e9294f
+				dup stringwidth setcharwidth
6e9294f
+				0 0 moveto show
6e9294f
+				grestore
6e9294f
+			    } bind def
6e9294f
+			    currentdict
6e9294f
+			end
6e9294f
+			/lowerbytefont exch definefont
6e9294f
+		    } forall
6e9294f
+		] def
6e9294f
+		currentdict
6e9294f
+	    end
6e9294f
+	    /eucfont exch definefont
6e9294f
+	    exch
6e9294f
+	    findfont 1 copyfont dup begin
6e9294f
+		RomanRotation {
6e9294f
+			/FontMatrix FontMatrix
6e9294f
+			[ 0 RomanScale neg RomanScale 0 RomanOffset neg 0 ]
6e9294f
+			matrix concatmatrix def
6e9294f
+		}{
6e9294f
+			/FontMatrix FontMatrix
6e9294f
+			[ RomanScale 0 0 RomanScale 0 RomanOffset ] matrix concatmatrix
6e9294f
+			def
6e9294f
+			/CDevProc
6e9294f
+			    {pop pop pop pop 0 exch -1000 exch 2 div 880} def
6e9294f
+		} ifelse
6e9294f
+	    end
6e9294f
+	    /asciifont exch definefont
6e9294f
+	    exch
6e9294f
+	    /FDepVector [ 4 2 roll ] def
6e9294f
+	    /FontType 0 def
6e9294f
+	    /WMode 0 def
6e9294f
+	    /FMapType 4 def
6e9294f
+	    /FontMatrix matrix def
6e9294f
+	    /Encoding [0 1] def
6e9294f
+	    /FontBBox {0 0 0 0} def
6e9294f
+%	    /FontHeight 1.0 def % XXXX
6e9294f
+	    /FontHeight RomanScale 1.0 ge { RomanScale }{ 1.0 } ifelse def
6e9294f
+	    /Descent -0.3 def   % XXXX
6e9294f
+	    currentdict
6e9294f
+	end
6e9294f
+	/tmpfont exch definefont
6e9294f
+	pop
6e9294f
+	/tmpfont findfont
6e9294f
+    }{
6e9294f
+	pop findfont 0 copyfont
6e9294f
+    } ifelse
6e9294f
+} def	
6e9294f
+
6e9294f
+/slantfont {	% FontName slant-degree  slantfont  font'
6e9294f
+    exch findfont 1 copyfont begin
6e9294f
+    [ 1 0 4 -1 roll 1 0 0 ] FontMatrix exch matrix concatmatrix
6e9294f
+    /FontMatrix exch def
6e9294f
+    currentdict
6e9294f
+    end
6e9294f
+} def
6e9294f
+
6e9294f
 % Function print line number (<string> # -)
6e9294f
 /# {
6e9294f
   gsave
6e9294f
diff -up /dev/null a2ps-4.14/README.eucJP
6e9294f
--- /dev/null	2008-04-27 11:55:27.307012118 +0200
6e9294f
+++ a2ps-4.14/README.eucJP	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -0,0 +1,100 @@
6e9294f
+a2ps euc-jp kanji supported patch:
6e9294f
+by SATO Satoru <ss@gnome.gr.jp>
6e9294f
+
6e9294f
+These patches enables a2ps to support the files written in EUC-JP (and other
6e9294f
+Japanese encodings). I only arranged patches created by FURUKAWA Yasuyuki,
6e9294f
+KATAYAMA Yukio, and replaced libjcode by customized jcode.[ch] (by KITAME
6e9294f
+Takuo).
6e9294f
+
6e9294f
+Notes from the orginal patch by FURUKAWA Yukihiro is follows.
6e9294f
+(sorry, it is written in japanese only):
6e9294f
+
6e9294f
+a2ps 4.12で漢字を印刷するためのパッチ
6e9294f
+				慶應大学大学院
6e9294f
+				古川 泰之 <yasu@on.cs.keio.ac.jp>
6e9294f
+
6e9294f
+composite font を使って漢字を表示するためのパッチです。
6e9294f
+composite fontには、片山 紀夫さん(はじめて日本語ghostscriptを作成した
6e9294f
+人)のfixeucfont をベースにa2ps用に多少手をいれております。これを利用す
6e9294f
+ることで、2バイトEUC+ASCIIの文字列のPostscriptの扱いがぐっと簡単にな
6e9294f
+ります。
6e9294f
+
6e9294f
+●Compositeフォントの設定方法について
6e9294f
+最低限の設定はパッチに含まれていますので、とりあえず大丈夫だとは思いま
6e9294f
+す。一応メモしておきます。
6e9294f
+
6e9294f
+encodingファイル($prefix/share/a2ps/encoding/の下のファイル)には
6e9294f
+『Composite:』および、『DefaultComposite:』が新たに指定できます。たと
6e9294f
+えば、英語フォントに対応するEUCエンコーディングの日本語フォントを書い
6e9294f
+て行きます。また、この際、フォント幅と半角と漢字の比も指定しなくてはな
6e9294f
+りません。手抜きによって、漢字は固定幅フォントしか指定してはいけません。
6e9294f
+
6e9294f
+--------------------------------------------------
6e9294f
+#	                  日本語フォント          フォン横幅	半角と漢字の比
6e9294f
+DefaultComposite:         Ryumin-Light-EUC-H      1             1.1	
6e9294f
+#	    英語フォント  日本語フォント	  フォン横幅	半角と漢字の比
6e9294f
+Composite:  Helvetica     GothicBBB-Medium-EUC-H  1		1.1
6e9294f
+--------------------------------------------------
6e9294f
+
6e9294f
+また、これだと斜体漢字がなく、さみしいので、SlantFontを使い、斜体の漢
6e9294f
+字フォントも作成できます。
6e9294f
+
6e9294f
+--------------------------------------------------
6e9294f
+#               新規斜体日本語フォント名	ソース日本語フォント	傾き度
6e9294f
+SlantFont:	Ryumin-Light-EUC-H-Italic	Ryumin-Light-EUC-H	0.2
6e9294f
+--------------------------------------------------
6e9294f
+
6e9294f
+SlantFontで生成した斜体フォントはCompositeフォント(第2引数)で利用でき
6e9294f
+ます。
6e9294f
+
6e9294f
+●このパッチの詳細データ
6e9294f
+  ・残念ながら2バイトEUCコードを前提としたコーディングをしています。
6e9294f
+    そのため、あまり漢字以外の言語を考えておりません…。
6e9294f
+  ・倉光 君郎氏のlibjcodeを使って内部で入力ファイルの漢字エンコーディ
6e9294f
+    ングをすべてEUCに変換して処理するようにしています。ただし、オリジ
6e9294f
+    ナルのlibjcodeは、SJISおよびEUCの判定が甘かったので多少カスタムし
6e9294f
+    ております。
6e9294f
+  ・また、texのdelegate(contrib/texi2dvi4a2ps)中、TeXドライバにはpTeX
6e9294f
+    と決めうちしています。これがいやなら、例えばNTT-jTeXを使用したい場
6e9294f
+    合、環境変数TEXに『jtex』を、LATEXには『jlatex』を指定してください。
6e9294f
+  ・compositefontをa2ps用に多少カスタマイズしていますが、フォントの高
6e9294f
+    さなどの情報を完全に固定で決め打ちしている箇所があります(XXXでメモ
6e9294f
+    しています)。そのためあまり応用性が低いと思います。
6e9294f
+
6e9294f
+●半角を全角の1/2の大きさにしたい
6e9294f
+パッチデフォルトでは全角文字と半角文字の大きさのバランスは、見た感じが
6e9294f
+(個人的なセンスで)安定するようにチューニングしています。もし、テキスト
6e9294f
+で表を作成していて、そのため、半角文字を全角のちょうど半分にそろえたい
6e9294f
+という場合の対処方法を書いておきます。
6e9294f
+
6e9294f
+インストール後、$prefix/share/a2ps/encoding/euc-jp中に、
6e9294f
+
6e9294f
+--------------------------------------------------
6e9294f
+DefaultComposite:         Ryumin-Light-EUC-H      1.0  1.1
6e9294f
+--------------------------------------------------
6e9294f
+
6e9294f
+というのがあると思います。最後の『1.1』を『0.8342』あたりに変更して下
6e9294f
+さい。ノーマル固定文字に関してはこれで望みの結果が得られると思います。
6e9294f
+
6e9294f
+他の太字フォントなども、例えば
6e9294f
+
6e9294f
+--------------------------------------------------
6e9294f
+Composite: Courier-Bold   GothicBBB-Medium-EUC-H  1.0  0.8342
6e9294f
+--------------------------------------------------
6e9294f
+
6e9294f
+のように変更すればいいと思います。なお、Courierがつかないフォント
6e9294f
+(Helvetica等)はもともとプロポーショナルフォントなので、固定幅にはでき
6e9294f
+ません。
6e9294f
+
6e9294f
+
6e9294f
+
6e9294f
+●再配布について
6e9294f
+なんだかんだいって、このパッチは、
6e9294f
+
6e9294f
+倉光 君郎さんのlibjcode  +  片山 紀夫さんのfixeucfont 
6e9294f
+
6e9294f
+を組み合わてできたもので私自身のコードは実はほとんどありません…。
6e9294f
+
6e9294f
+私自身のコードは再配付/改造に関してなんら制限を設けるつもりはありませ
6e9294f
+ん。ただし、私以外のコードの方が多いため、一応それだけは御了承お願い致
6e9294f
+します。
6e9294f
diff -up a2ps-4.14/src/buffer.c.euc a2ps-4.14/src/buffer.c
6e9294f
--- a2ps-4.14/src/buffer.c.euc	2007-12-29 02:58:34.000000000 +0100
6e9294f
+++ a2ps-4.14/src/buffer.c	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -41,6 +41,21 @@
6e9294f
 #include "argmatch.h"
6e9294f
 #include "buffer.h"
6e9294f
 #include <assert.h>
6e9294f
+
6e9294f
+#ifdef HAVE_CONFIG_H
6e9294f
+# include <config.h>
6e9294f
+#endif
6e9294f
+
6e9294f
+#ifdef ENABLE_KANJI
6e9294f
+#  include <stdio.h>
6e9294f
+#  include <stdlib.h>
6e9294f
+#  include <string.h>
6e9294f
+#  include <locale.h>
6e9294f
+#  include <errno.h>
6e9294f
+#  include <iconv.h>
6e9294f
+extern use_jcode;
6e9294f
+#endif
6e9294f
+
6e9294f
 
6e9294f
 /****************************************************************/
6e9294f
 /*		 	Handling of the various eol styles	*/
6e9294f
@@ -526,3 +541,278 @@ buffer_test (const char *filename)
6e9294f
   buffer_release (&buffer);
6e9294f
 }
6e9294f
 #endif
6e9294f
+
6e9294f
+/**
6e9294f
+ * from jcode.c by Takuo KITAME <kitame@northeye.org>
6e9294f
+ */
6e9294f
+#ifdef ENABLE_KANJI
6e9294f
+
6e9294f
+enum {
6e9294f
+    JCODE_ASCII,
6e9294f
+    JCODE_EUC,
6e9294f
+    JCODE_JIS,
6e9294f
+    JCODE_SJIS,
6e9294f
+    EUCORSJIS };
6e9294f
+
6e9294f
+#define ESC          0x1b
6e9294f
+#define SS2          0x8e
6e9294f
+
6e9294f
+#define JCODE_LOCALE_EUC   "ja", "ja_JP", "ja_JP.ujis", "ja_JP.EUC", "ja_JP.eucJP"
6e9294f
+#define JCODE_LOCALE_JIS   "ja_JP.JIS", "ja_JP.jis", "ja_JP.iso-2022-jp"
6e9294f
+#define JCODE_LOCALE_SJIS  "ja_JP.SJIS", "ja_JP.sjis"
6e9294f
+
6e9294f
+/****************************************************************************/
6e9294f
+/* Japanese string code detector */
6e9294f
+/****************************************************************************/
6e9294f
+int 
6e9294f
+detect_kanji(unsigned char *str)
6e9294f
+{
6e9294f
+    int expected = JCODE_ASCII;
6e9294f
+    register int c;
6e9294f
+    int c1, c2;
6e9294f
+    int euc_c = 0, sjis_c = 0;
6e9294f
+    unsigned char *ptr = str;
6e9294f
+    
6e9294f
+    while((c = (int)*ptr)!= '\0') {
6e9294f
+        if(c == ESC) {
6e9294f
+            if((c = (int)*(++ptr)) == '\0')
6e9294f
+                break;
6e9294f
+            if(c == '$') {
6e9294f
+                if((c = (int)*(++ptr)) == '\0')
6e9294f
+                    break;
6e9294f
+                if(c == 'B' || c == '@')
6e9294f
+                    return JCODE_JIS;
6e9294f
+            }
6e9294f
+            ptr++;
6e9294f
+            continue;
6e9294f
+        }
6e9294f
+        if((c >= 0x81 && c <= 0x8d) || (c >= 0x8f && c <= 0x9f))
6e9294f
+            return JCODE_SJIS;
6e9294f
+        
6e9294f
+        if(c == SS2) {
6e9294f
+            if((c = (int)*(++ptr)) == '\0')
6e9294f
+                break;
6e9294f
+            if((c >= 0x40 && c <= 0x7e) ||
6e9294f
+               (c >= 0x80 && c <= 0xa0) || 
6e9294f
+               (c >= 0xe0 && c <= 0xfc))
6e9294f
+                return JCODE_SJIS;
6e9294f
+            if(c >= 0xa1 && c <= 0xdf)
6e9294f
+                break;
6e9294f
+            
6e9294f
+            ptr++;
6e9294f
+            continue;
6e9294f
+        }        
6e9294f
+        if(c >= 0xa1 && c <= 0xdf) {
6e9294f
+            if((c = (int)*(++ptr)) == '\0')
6e9294f
+                break;
6e9294f
+            
6e9294f
+            if (c >= 0xe0 && c <= 0xfe)
6e9294f
+                return JCODE_EUC;
6e9294f
+            if (c >= 0xa1 && c <= 0xdf) {
6e9294f
+                expected = EUCORSJIS;
6e9294f
+                ptr++;
6e9294f
+                continue;
6e9294f
+            }
6e9294f
+#if 1
6e9294f
+            if(c == 0xa0 || (0xe0 <= c && c <= 0xfe))
6e9294f
+                return JCODE_EUC;
6e9294f
+            else {
6e9294f
+                expected = EUCORSJIS;
6e9294f
+                ptr++;
6e9294f
+                continue;
6e9294f
+            }
6e9294f
+#else
6e9294f
+            if(c <= 0x9f)
6e9294f
+                return JCODE_SJIS;
6e9294f
+            if(c >= 0xf0 && c <= 0xfe)
6e9294f
+                return JCODE_EUC;
6e9294f
+#endif
6e9294f
+            
6e9294f
+            if(c >= 0xe0 && c <= 0xef) {
6e9294f
+                expected = EUCORSJIS;
6e9294f
+                while(c >= 0x40) {
6e9294f
+                    if(c >= 0x81) {
6e9294f
+                        if(c <= 0x8d || (c >= 0x8f && c <= 0x9f))
6e9294f
+                            return JCODE_SJIS;
6e9294f
+                        else if(c >= 0xfd && c <= 0xfe) {
6e9294f
+                            return JCODE_EUC;
6e9294f
+                        }
6e9294f
+                    }
6e9294f
+                    if((c = (int)*(++ptr)) == '\0')
6e9294f
+                        break;
6e9294f
+                }
6e9294f
+                ptr++;
6e9294f
+                continue;
6e9294f
+            }
6e9294f
+            
6e9294f
+            if(c >= 0xe0 && c <= 0xef) {
6e9294f
+                if((c = (int)*(++ptr)) == '\0')
6e9294f
+                    break;
6e9294f
+                if((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xa0))
6e9294f
+                    return JCODE_SJIS;
6e9294f
+                if(c >= 0xfd && c <= 0xfe)
6e9294f
+                    return JCODE_EUC;
6e9294f
+                if(c >= 0xa1 && c <= 0xfc)
6e9294f
+                    expected = EUCORSJIS;
6e9294f
+            }
6e9294f
+        }
6e9294f
+#if 1
6e9294f
+        if (0xf0 <= c && c <= 0xfe)
6e9294f
+            return JCODE_EUC;
6e9294f
+#endif
6e9294f
+        ptr++;
6e9294f
+    }
6e9294f
+
6e9294f
+   ptr = str;
6e9294f
+   c2 = 0;
6e9294f
+   while((c1 = (int)*ptr++) != '\0') {
6e9294f
+       if(((c2 >  0x80 && c2 < 0xa0) || (c2 >= 0xe0 && c2 < 0xfd)) &&
6e9294f
+          ((c1 >= 0x40 && c1 < 0x7f) || (c1 >= 0x80 && c1 < 0xfd)))
6e9294f
+           sjis_c++, c1 = *ptr++;
6e9294f
+       c2 = c1;
6e9294f
+   }
6e9294f
+   if(sjis_c == 0)
6e9294f
+       expected = JCODE_EUC;
6e9294f
+   else {
6e9294f
+       ptr = str, c2 = 0;
6e9294f
+       while((c1 = (int)*ptr++) != '\0') {
6e9294f
+	     if((c2 > 0xa0  && c2 < 0xff) &&
6e9294f
+            (c1 > 0xa0  && c1 < 0xff))
6e9294f
+             euc_c++, c1 = *ptr++;
6e9294f
+	     c2 = c1;
6e9294f
+       }
6e9294f
+       if(sjis_c > euc_c)
6e9294f
+           expected = JCODE_SJIS;
6e9294f
+       else
6e9294f
+           expected = JCODE_EUC;
6e9294f
+   }
6e9294f
+   return expected;
6e9294f
+}
6e9294f
+
6e9294f
+int
6e9294f
+int_detect_JCode(char *str)
6e9294f
+{
6e9294f
+    int detected;
6e9294f
+
6e9294f
+    if(!str)
6e9294f
+        return 0;
6e9294f
+
6e9294f
+    detected = detect_kanji((unsigned char *)str);
6e9294f
+    
6e9294f
+    if(detected == JCODE_ASCII)
6e9294f
+        return JCODE_ASCII;
6e9294f
+    
6e9294f
+    switch(detected) {
6e9294f
+    case JCODE_EUC:
6e9294f
+        return JCODE_EUC;
6e9294f
+        break;
6e9294f
+    case JCODE_JIS:
6e9294f
+        return JCODE_JIS;
6e9294f
+        break;
6e9294f
+    case JCODE_SJIS:  
6e9294f
+        return JCODE_SJIS;
6e9294f
+        break;
6e9294f
+    default:
6e9294f
+        return JCODE_ASCII;
6e9294f
+        break;
6e9294f
+    }
6e9294f
+    
6e9294f
+    /* not reached */
6e9294f
+    return 0;
6e9294f
+}
6e9294f
+
6e9294f
+const char *
6e9294f
+detect_JCode(char *str)
6e9294f
+{
6e9294f
+    int detected;
6e9294f
+
6e9294f
+    if(!str)
6e9294f
+        return NULL;
6e9294f
+
6e9294f
+    detected = detect_kanji((unsigned char *)str);
6e9294f
+    
6e9294f
+    if(detected == JCODE_ASCII)
6e9294f
+        return "ASCII";
6e9294f
+
6e9294f
+    switch(detected) {
6e9294f
+    case JCODE_EUC:
6e9294f
+        return "EUC-JP";
6e9294f
+        break;
6e9294f
+    case JCODE_JIS:
6e9294f
+        return "ISO-2022-JP";
6e9294f
+        break;
6e9294f
+    case JCODE_SJIS:  
6e9294f
+        return "SJIS";
6e9294f
+        break;
6e9294f
+    default:
6e9294f
+        return "ASCII";
6e9294f
+        break;
6e9294f
+    }
6e9294f
+    
6e9294f
+    /* not reached */
6e9294f
+    return 0;
6e9294f
+}
6e9294f
+
6e9294f
+char *
6e9294f
+kanji_conv_auto(char *str, const char *dstset)
6e9294f
+{
6e9294f
+    unsigned char *buf, *ret;
6e9294f
+    iconv_t cd;
6e9294f
+    size_t insize = 0;
6e9294f
+    size_t outsize = 0;
6e9294f
+    size_t nconv = 0;
6e9294f
+    char *inptr;
6e9294f
+    char *outptr;
6e9294f
+    char srcset[16];
6e9294f
+    
6e9294f
+    if(!str)
6e9294f
+        return NULL;
6e9294f
+    
6e9294f
+    switch (int_detect_JCode(str)) {
6e9294f
+    case JCODE_EUC:
6e9294f
+        strcpy(srcset, "EUC-JP");
6e9294f
+        break;
6e9294f
+    case JCODE_JIS:
6e9294f
+        strcpy(srcset, "ISO-2022-JP");
6e9294f
+        break;
6e9294f
+    case JCODE_SJIS:
6e9294f
+        strcpy(srcset, "SJIS");
6e9294f
+        break;
6e9294f
+    default:
6e9294f
+        return strdup(str);
6e9294f
+        break;
6e9294f
+    }
6e9294f
+    
6e9294f
+    buf = (unsigned char *)malloc(strlen(str)* 4 + 1);
6e9294f
+    if(!buf)
6e9294f
+        return NULL;
6e9294f
+    
6e9294f
+    insize = strlen(str);
6e9294f
+    inptr = str;
6e9294f
+    outsize = strlen(str) * 4 ;
6e9294f
+    outptr = buf;
6e9294f
+    
6e9294f
+    cd = iconv_open(dstset, srcset);
6e9294f
+    if(cd == (iconv_t) -1) {
6e9294f
+        if(errno == EINVAL)
6e9294f
+            return strdup(str);
6e9294f
+    }
6e9294f
+    
6e9294f
+    nconv = iconv(cd, (const char **)&inptr, &insize, &outptr, &outsize);
6e9294f
+    if(nconv == (size_t) -1) {
6e9294f
+        if (errno == EINVAL)
6e9294f
+            memmove (buf, inptr, insize);
6e9294f
+    } else
6e9294f
+        iconv(cd, NULL, NULL, &outptr, &outsize);
6e9294f
+    
6e9294f
+    *outptr = '\0';
6e9294f
+    iconv_close(cd);
6e9294f
+    
6e9294f
+    ret = strdup(buf);
6e9294f
+    free(buf);
6e9294f
+    
6e9294f
+    return ret;
6e9294f
+}
6e9294f
+
6e9294f
+#endif
6e9294f
+
6e9294f
diff -up a2ps-4.14/src/buffer.h.euc a2ps-4.14/src/buffer.h
6e9294f
--- a2ps-4.14/src/buffer.h.euc	2007-12-29 02:58:35.000000000 +0100
6e9294f
+++ a2ps-4.14/src/buffer.h	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -104,4 +104,15 @@ void buffer_sample_get PARAMS ((buffer_t
6e9294f
 void buffer_save PARAMS ((buffer_t * buffer, const char * filename));
6e9294f
 
6e9294f
 #define buffer_is_empty(Buf) (Buf->curr >= Buf->len)
6e9294f
+
6e9294f
+
6e9294f
+/**
6e9294f
+ * from jcode.h by Takuo KITAME
6e9294f
+ */
6e9294f
+
6e9294f
+char *kanji_conv_auto(char *str, const char *dstset);
6e9294f
+
6e9294f
+const char *detect_JCode(char *str);
6e9294f
+int int_detect_JCode(char *str);
6e9294f
+
6e9294f
 #endif
6e9294f
diff -up a2ps-4.14/src/Makefile.am.euc a2ps-4.14/src/Makefile.am
6e9294f
--- a2ps-4.14/src/Makefile.am.euc	2007-12-29 02:36:09.000000000 +0100
6e9294f
+++ a2ps-4.14/src/Makefile.am	2008-04-27 10:39:24.000000000 +0200
6e9294f
@@ -33,13 +33,13 @@ DEFS = @DEFS@ -DLOCALEDIR=\"$(datadir)/l
6e9294f
 a2ps_SOURCES = main.c \
6e9294f
 read.c sshread.c ssheet.c select.c generate.c 			\
6e9294f
 delegate.c regex.c buffer.c versions.c ffaces.c			\
6e9294f
-version-etc.c long-options.c					\
6e9294f
+version-etc.c long-options.c jcode.c				\
6e9294f
 parsessh.y lexssh.l lexps.l sheets-map.l
6e9294f
 
6e9294f
 noinst_HEADERS = main.h \
6e9294f
 read.h sshread.h ssheet.h select.h generate.h			\
6e9294f
 delegate.h regex.h buffer.h versions.h ffaces.h			\
6e9294f
-version-etc.h long-options.h					\
6e9294f
+version-etc.h long-options.h jcode.h				\
6e9294f
 yy2ssh.h lexps.h
6e9294f
 
6e9294f
 BUILT_SOURCES = parsessh.c parsessh.h