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