Blame SOURCES/a2ps-4.13-eucjp.patch

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