Blame SOURCES/a2ps-4.13-eucjp.patch

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