Blame SOURCES/a2ps-4.13-eucjp.patch

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