6895N/AComposite fonts support, needed for handling Japanese EUC-JP encoding
6895N/ARoughly based on Yasuyuki Furukawa's patch
6895N/A
6895N/ASee: https://patches.ubuntu.com/by-release/extracted/ubuntu/a/a2ps/1:4.13c~rc5-1/02_composite_fonts.dpatch
6895N/A
6895N/A## 02_composite_fonts.dpatch by Masayuki Hatta <mhatta@debian.org>
6895N/A
6895N/AIndex: b/encoding/Makefile.am
6895N/A===================================================================
6895N/A--- a/encoding/Makefile.am
6895N/A+++ b/encoding/Makefile.am
6895N/A@@ -16,7 +16,7 @@
6895N/A minor_encodings = \
6895N/A ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf \
6895N/A iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf \
6895N/A-iso15.edf koi8.edf ms-cp1251.edf
6895N/A+iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
6895N/A
6895N/A if EXTENSIONS
6895N/A encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
6895N/AIndex: b/encoding/Makefile.in
6895N/A===================================================================
6895N/A--- a/encoding/Makefile.in
6895N/A+++ b/encoding/Makefile.in
6895N/A@@ -270,7 +270,7 @@
6895N/A minor_encodings = \
6895N/A ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf \
6895N/A iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf \
6895N/A-iso15.edf koi8.edf ms-cp1251.edf
6895N/A+iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
6895N/A
6895N/A @EXTENSIONS_FALSE@encodings_DATA = encoding.map $(major_encodings)
6895N/A @EXTENSIONS_TRUE@encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
6895N/AIndex: b/encoding/encoding.map
6895N/A===================================================================
6895N/A--- a/encoding/encoding.map
6895N/A+++ b/encoding/encoding.map
6895N/A@@ -93,6 +93,12 @@
6895N/A koi8 koi8
6895N/A koi koi8
6895N/A
6895N/A+euc-jp euc-jp
6895N/A+eucjp euc-jp
6895N/A+japanese euc-jp
6895N/A+ja euc-jp
6895N/A+jp euc-jp
6895N/A+
6895N/A ########################################################################
6895N/A # Some architectures specific char sets
6895N/A ########################################################################
6895N/AIndex: b/encoding/euc-jp.edf
6895N/A===================================================================
6895N/A--- /dev/null
6895N/A+++ b/encoding/euc-jp.edf
6895N/A@@ -0,0 +1,95 @@
6895N/A+# Description of the EUC-JP encoding
6895N/A+# Copyright (c) 1988, 89, 90, 91, 92, 93 Miguel Santana
6895N/A+# Copyright (c) 1995, 96, 97, 98 Akim Demaille, Miguel Santana
6895N/A+# Copyright (c) 2003 Masayuki Hatta
6895N/A+#
6895N/A+
6895N/A+# This program is free software; you can redistribute it and/or modify
6895N/A+# it under the terms of the GNU General Public License as published by
6895N/A+# the Free Software Foundation; either version 2, or (at your option)
6895N/A+# any later version.
6895N/A+#
6895N/A+# This program is distributed in the hope that it will be useful,
6895N/A+# but WITHOUT ANY WARRANTY; without even the implied warranty of
6895N/A+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6895N/A+# GNU General Public License for more details.
6895N/A+#
6895N/A+# You should have received a copy of the GNU General Public License
6895N/A+# along with this program; see the file COPYING. If not, write to
6895N/A+# the Free Software Foundation, 59 Temple Place - Suite 330,
6895N/A+# Boston, MA 02111-1307, USA.
6895N/A+#
6895N/A+
6895N/A+Name: EUC-JP
6895N/A+
6895N/A+Documentation
6895N/A+The EUC-JP encoding is a 8-bit character set widely used in Japan.
6895N/A+EndDocumentation
6895N/A+
6895N/A+# If there is an unknown font requested, use Courier
6895N/A+Default: Courier
6895N/A+
6895N/A+# Automatic spell checking :)
6895N/A+Substitute: Times Times-Roman
6895N/A+Substitute: Helvetica-Italic Helvetica-Oblique
6895N/A+Substitute: Helvetica-BoldItalic Helvetica-BoldOblique
6895N/A+
6895N/A+
6895N/A+# SlantFont for Japanese Italic Kanji font
6895N/A+# new font source font value
6895N/A+SlantFont: Ryumin-Light-EUC-H-Italic Ryumin-Light-EUC-H 0.2
6895N/A+SlantFont: GothicBBB-Medium-EUC-H-Italic GothicBBB-Medium-EUC-H 0.2
6895N/A+
6895N/A+# Compose fonts for Japanese EUC code
6895N/A+# target font additional font width size rate
6895N/A+DefaultComposite: Ryumin-Light-EUC-H 1.0 1.1
6895N/A+
6895N/A+# 1:2 fixed
6895N/A+#DefaultComposite: Ryumin-Light-EUC-H 1.0 0.8333
6895N/A+
6895N/A+# 1:1 fixed
6895N/A+#DefaultComposite: Ryumin-Light-EUC-H 1.0 1.6666
6895N/A+
6895N/A+Composite: Helvetica GothicBBB-Medium-EUC-H 1.0 1.1
6895N/A+Composite: Helvetica-Oblique GothicBBB-Medium-EUC-H-Italic 1.0 1.1
6895N/A+Composite: Helvetica-Bold GothicBBB-Medium-EUC-H 1.0 1.1
6895N/A+Composite: Helvetica-BoldOblique GothicBBB-Medium-EUC-H-Italic 1.0 1.1
6895N/A+
6895N/A+Composite: Courier-Oblique Ryumin-Light-EUC-H-Italic 1.0 1.1
6895N/A+Composite: Courier-Bold GothicBBB-Medium-EUC-H 1.0 1.1
6895N/A+Composite: Courier-BoldOblique GothicBBB-Medium-EUC-H-Italic 1.0 1.1
6895N/A+Composite: Times-Bold GothicBBB-Medium-EUC-H 1.0 1.1
6895N/A+
6895N/A+Vector:
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+space exclam quotedbl numbersign dollar percent ampersand quoteright
6895N/A+parenleft parenright asterisk plus comma minus period slash
6895N/A+zero one two three four five six seven
6895N/A+eight nine colon semicolon less equal greater question
6895N/A+at A B C D E F G
6895N/A+H I J K L M N O
6895N/A+P Q R S T U V W
6895N/A+X Y Z bracketleft backslash bracketright asciicircum underscore
6895N/A+quoteleft a b c d e f g
6895N/A+h i j k l m n o
6895N/A+p q r s t u v w
6895N/A+x y z braceleft bar braceright asciitilde .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6895N/A+space exclamdown cent sterling currency yen brokenbar section
6895N/A+dieresis copyright ordfeminine guillemotleft logicalnot hyphen registered macron
6895N/A+degree plusminus twosuperior threesuperior acute mu paragraph bullet
6895N/A+cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown
6895N/A+Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla
6895N/A+Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
6895N/A+Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply
6895N/A+Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls
6895N/A+agrave aacute acircumflex atilde adieresis aring ae ccedilla
6895N/A+egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis
6895N/A+eth ntilde ograve oacute ocircumflex otilde odieresis divide
6895N/A+oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
6895N/AIndex: b/lib/encoding.c
6895N/A===================================================================
6895N/A--- a/lib/encoding.c
6895N/A+++ b/lib/encoding.c
6895N/A@@ -389,15 +389,25 @@
6895N/A * Association of suffixes rules, and corresponding style sheet
6895N/A * (The hashing is upon `alias')
6895N/A */
6895N/A+struct slantfont_info {
6895N/A+ char * name;
6895N/A+ char * src;
6895N/A+ float ratio;
6895N/A+};
6895N/A+
6895N/A struct encoding {
6895N/A char * key; /* e.g. latin1 */
6895N/A char * name; /* e.g. ISO Latin 1 */
6895N/A+ int composite_flag; /* flag for composite font */
6895N/A uchar * documentation; /* Useful pieces of text */
6895N/A
6895N/A char * default_font; /* When a font can't be used
6895N/A define the font to use */
6895N/A struct pair_htable * substitutes; /* e.g. in latin2, don't use
6895N/A * Courier, but Courier-Ogonki */
6895N/A+ struct pair_htable * composite;
6895N/A+
6895N/A+ struct slantfont_info slantfont[NB_FACES];
6895N/A
6895N/A char * vector[256]; /* Define the char set */
6895N/A struct darray * font_names_used;
6895N/A@@ -407,6 +417,9 @@
6895N/A struct hash_table_s * fonts; /* Contains cells that are
6895N/A * 1. name of font, 2. int wx[256] */
6895N/A unsigned int * faces_wx[NB_FACES];
6895N/A+
6895N/A+ unsigned int composite_wx[NB_FACES]; /* fixed length font width */
6895N/A+ float composite_ratio[NB_FACES]; /* size ratio of additonal and original font */
6895N/A };
6895N/A
6895N/A /*
6895N/A@@ -423,9 +436,12 @@
6895N/A res->name = NULL;
6895N/A res->default_font = NULL;
6895N/A res->documentation = NULL;
6895N/A+ res->composite_flag = false;
6895N/A
6895N/A /* Vector will be set by setup */
6895N/A res->substitutes = pair_table_new ();
6895N/A+ res->composite = pair_table_new ();
6895N/A+ res->slantfont[0].name = NULL;
6895N/A res->font_names_used = da_new ("List of font names", 10,
6895N/A da_linear, 10,
6895N/A (da_print_func_t) da_str_print,
6895N/A@@ -471,6 +487,34 @@
6895N/A }
6895N/A
6895N/A /*
6895N/A+ * Add a composite font in the current encoding
6895N/A+ */
6895N/A+static void
6895N/A+encoding_add_composite_font (struct encoding * encoding,
6895N/A+ const char * orig, const char * subs,
6895N/A+ int wx, float ratio)
6895N/A+{
6895N/A+ encoding->composite_flag = true;
6895N/A+ pair_add2 (encoding->composite, orig, subs, wx, ratio);
6895N/A+}
6895N/A+
6895N/A+/*
6895N/A+ * Add a composite font in the current encoding
6895N/A+ */
6895N/A+static void
6895N/A+encoding_add_slant_font (struct encoding * encoding,
6895N/A+ const char * new, const char * src,
6895N/A+ float ratio)
6895N/A+{
6895N/A+ static num = 0;
6895N/A+ encoding->slantfont[num].name = strdup(new);
6895N/A+ encoding->slantfont[num].src = strdup(src);
6895N/A+ encoding->slantfont[num].ratio = ratio;
6895N/A+ encoding->slantfont[num+1].name = NULL;
6895N/A+ num++;
6895N/A+}
6895N/A+
6895N/A+/*
6895N/A * When FONT_NAME is used with ENCODING, return the
6895N/A * real font name to use (e.g., in latin2, Courier-Ogonki
6895N/A * should be returned when asked for Courier).
6895N/A@@ -514,6 +558,77 @@
6895N/A }
6895N/A
6895N/A message (msg_enc,
6895N/A+ (stderr, "In encoding %s, composite font for %s is resolved as %s\n",
6895N/A+ encoding->key, font_name, res));
6895N/A+ return res;
6895N/A+}
6895N/A+
6895N/A+/*
6895N/A+ * Get composite font size and ratio
6895N/A+ */
6895N/A+static int
6895N/A+composite_font_info_get_wx(struct a2ps_job * job,
6895N/A+ struct encoding * encoding,
6895N/A+ const char * font_list)
6895N/A+{
6895N/A+ int wx= -1;
6895N/A+ char * font_list_copy;
6895N/A+ char * font_name;
6895N/A+ astrcpy (font_list_copy, font_list);
6895N/A+ font_name = strtok (font_list_copy, ",<>;");
6895N/A+
6895N/A+ wx = pair_get_wx (encoding->composite, font_name);
6895N/A+ if (wx<0)
6895N/A+ wx = pair_get_wx (encoding->composite, "default_composite__");
6895N/A+
6895N/A+ return wx;
6895N/A+}
6895N/A+
6895N/A+static float
6895N/A+composite_font_info_get_ratio(struct a2ps_job * job,
6895N/A+ struct encoding * encoding,
6895N/A+ const char * font_list)
6895N/A+{
6895N/A+ float ratio= -1;
6895N/A+ char * font_list_copy;
6895N/A+ char * font_name;
6895N/A+
6895N/A+ astrcpy (font_list_copy, font_list);
6895N/A+ font_name = strtok (font_list_copy, ",<>;");
6895N/A+
6895N/A+ ratio = pair_get_ratio (encoding->composite, font_name);
6895N/A+ if (ratio<0)
6895N/A+ ratio = pair_get_ratio (encoding->composite, "default_composite__");
6895N/A+ return ratio;
6895N/A+}
6895N/A+
6895N/A+const char *
6895N/A+encoding_resolve_composite_font (struct a2ps_job * job,
6895N/A+ struct encoding * encoding,
6895N/A+ const char * font_list)
6895N/A+{
6895N/A+ const char * res = NULL;
6895N/A+ char * font_list_copy;
6895N/A+ char * font_name;
6895N/A+
6895N/A+ astrcpy (font_list_copy, font_list);
6895N/A+ font_name = strtok (font_list_copy, ",<>;");
6895N/A+
6895N/A+ /* Find if there is a substitute for that font */
6895N/A+ res = pair_get (encoding->composite, font_name);
6895N/A+
6895N/A+ /* We've found nothing interesting. Last chance is the default
6895N/A+ * font */
6895N/A+ if (!res)
6895N/A+ {
6895N/A+ res = pair_get (encoding->composite, "default_composite__");
6895N/A+
6895N/A+ if (!res)
6895N/A+ error (1, 0, "Cannot find font %s, nor any composite font",
6895N/A+ font_name);
6895N/A+ }
6895N/A+
6895N/A+ message (msg_enc,
6895N/A (stderr, "In encoding %s, font %s is resolved as %s\n",
6895N/A encoding->key, font_name, res));
6895N/A return res;
6895N/A@@ -633,6 +748,66 @@
6895N/A subs = token2;
6895N/A encoding_add_font_substitute (encoding, orig, subs);
6895N/A }
6895N/A+ else if (strequ (token, "DefaultComposite:"))
6895N/A+ {
6895N/A+ char * orig, * subs;
6895N/A+ int wx;
6895N/A+ float ratio;
6895N/A+
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ subs = token2;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ wx = (int)atof(token2)*1000;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ ratio = atof(token2);
6895N/A+ encoding_add_composite_font(encoding, "default_composite__",
6895N/A+ subs, wx, ratio);
6895N/A+ }
6895N/A+ else if (strequ (token, "Composite:"))
6895N/A+ {
6895N/A+ char * orig, * subs;
6895N/A+ int wx;
6895N/A+ float ratio;
6895N/A+
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ orig = token2;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ subs = token2;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ wx = (int)atof(token2)*1000;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ ratio = atof(token2);
6895N/A+ encoding_add_composite_font(encoding, orig, subs, wx, ratio);
6895N/A+ }
6895N/A+ else if (strequ (token, "SlantFont:"))
6895N/A+ {
6895N/A+ char * new, * src;
6895N/A+ float ratio;
6895N/A+ unsigned int num;
6895N/A+
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ new = token2;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ src = token2;
6895N/A+ token2 = GET_TOKEN (NULL);
6895N/A+ CHECK_TOKEN ();
6895N/A+ ratio = atof(token2);
6895N/A+ for (num = 0 ; encoding->slantfont[num].name ; num ++ );
6895N/A+ if (num > sizeof encoding->slantfont - 1){
6895N/A+ error_at_line (1, 0, fname, firstline,
6895N/A+ _("too many slant font: `%s'"), new);
6895N/A+ }
6895N/A+ encoding_add_slant_font(encoding, new, src, ratio);
6895N/A+ }
6895N/A else
6895N/A error_at_line (1, 0, fname, firstline,
6895N/A _("invalid option `%s'"), quotearg (token));
6895N/A@@ -754,6 +929,15 @@
6895N/A }
6895N/A
6895N/A /*
6895N/A+ * Return the flag of composite flag
6895N/A+ */
6895N/A+int
6895N/A+encoding_get_composite_flag (struct encoding * enc)
6895N/A+{
6895N/A+ return enc->composite_flag;
6895N/A+}
6895N/A+
6895N/A+/*
6895N/A * Prepare the environment (a dictionary) for the support
6895N/A * of ENCODING, dump it into STREAM.
6895N/A *
6895N/A@@ -766,9 +950,11 @@
6895N/A struct encoding * encoding)
6895N/A {
6895N/A size_t i, nb;
6895N/A+ size_t ns;
6895N/A const char * real_font_name; /* After subsitution */
6895N/A char ** font_names = (char **) encoding->font_names_used->content;
6895N/A
6895N/A+
6895N/A /* How many fonts are there? */
6895N/A da_qsort (encoding->font_names_used);
6895N/A da_unique (encoding->font_names_used, (da_map_func_t) free);
6895N/A@@ -787,15 +973,46 @@
6895N/A * in the current ENCODING */
6895N/A nb = encoding->font_names_used->len;
6895N/A
6895N/A+ /* The number of slant fonts */
6895N/A+ for (i= 0, ns=0 ; encoding->slantfont[i].name ; i++ )
6895N/A+ ns++;
6895N/A+
6895N/A /* Create the dictionary and fill it */
6895N/A fprintf (stream, "%% Dictionary for %s support\n",
6895N/A encoding->name);
6895N/A- fprintf (stream, "/%sdict %d dict begin\n", encoding->key, nb);
6895N/A+ fprintf (stream, "/%sdict %d dict begin\n", encoding->key,
6895N/A+ (encoding->composite_flag == true)? nb+nb+ns:nb+ns);
6895N/A for (i = 0 ; i < nb ; i++)
6895N/A fprintf (stream, " /f%s %sEncoding /%s reencode_font\n",
6895N/A font_names [i],
6895N/A encoding->name,
6895N/A encoding_resolve_font_substitute (job, encoding, font_names [i]));
6895N/A+
6895N/A+ /* Slant font setting */
6895N/A+ for (i = 0 ; encoding->slantfont[i].name ; i++ )
6895N/A+ fprintf (stream, " /%s /%s %f slantfont definefont pop\n",
6895N/A+ encoding->slantfont[i].name,
6895N/A+ encoding->slantfont[i].src,
6895N/A+ encoding->slantfont[i].ratio);
6895N/A+
6895N/A+ /*
6895N/A+ * Composite font setting.
6895N/A+ * If kanji font size is larger than alphabet character,
6895N/A+ * set base font size to kanji charactor size.
6895N/A+ */
6895N/A+ if (encoding->composite_flag == true) {
6895N/A+ for (i = 0 ; i < nb ; i++)
6895N/A+ fprintf (stream, " /f%s /f%s /%s %f %f false compositefont "
6895N/A+ "%f scalefont def\n",
6895N/A+ font_names [i],
6895N/A+ font_names [i],
6895N/A+ encoding_resolve_composite_font (job, encoding, font_names [i]),
6895N/A+ encoding->composite_ratio[i],
6895N/A+ (encoding->composite_ratio[i] > 1.0)?
6895N/A+ 0: (1-encoding->composite_ratio[i])/2.0,
6895N/A+ (encoding->composite_ratio[i] > 1.0)?
6895N/A+ 1.0/encoding->composite_ratio[i]: 1.0 );
6895N/A+ }
6895N/A fputs ("currentdict end def\n", stream);
6895N/A }
6895N/A
6895N/A@@ -939,6 +1156,22 @@
6895N/A true_font_name,
6895N/A encoding->vector,
6895N/A encoding->faces_wx [face]);
6895N/A+
6895N/A+ if (encoding->composite_flag)
6895N/A+ {
6895N/A+ encoding->composite_ratio[i] =
6895N/A+ composite_font_info_get_ratio(job, encoding,
6895N/A+ job->face_eo_font [face]);
6895N/A+
6895N/A+ encoding->composite_wx[i] =
6895N/A+ composite_font_info_get_wx(job, encoding,
6895N/A+ job->face_eo_font [face]);
6895N/A+
6895N/A+ /* If kanji font size is larger than alphabet character,
6895N/A+ fit kanji charactor size to base font size */
6895N/A+ if (encoding->composite_ratio[i] < 1.0)
6895N/A+ encoding->composite_wx[i] *= encoding->composite_ratio[i];
6895N/A+ }
6895N/A }
6895N/A }
6895N/A
6895N/A@@ -1073,6 +1306,13 @@
6895N/A return 0; /* For -Wall */
6895N/A }
6895N/A
6895N/A+unsigned int
6895N/A+char_composite_WX (a2ps_job * job, uchar c)
6895N/A+{
6895N/A+ return (job->encoding->composite_wx[job->status->face]/
6895N/A+ job->encoding->composite_ratio[job->status->face]);
6895N/A+}
6895N/A+
6895N/A /*
6895N/A * Returns the WX of a string (including M- and ^)
6895N/A */
6895N/AIndex: b/lib/encoding.h
6895N/A===================================================================
6895N/A--- a/lib/encoding.h
6895N/A+++ b/lib/encoding.h
6895N/A@@ -43,6 +43,7 @@
6895N/A */
6895N/A unsigned int char_WX PARAMS ((struct a2ps_job * job, uchar c));
6895N/A unsigned int string_WX PARAMS ((struct a2ps_job * job, uchar * string));
6895N/A+unsigned int char_composite_WX PARAMS ((struct a2ps_job * job, uchar c));
6895N/A
6895N/A
6895N/A /************************************************************************/
6895N/A@@ -56,6 +57,7 @@
6895N/A FILE * stream));
6895N/A int encoding_char_exists PARAMS ((struct encoding * enc,
6895N/A enum face_e face, uchar c));
6895N/A+int encoding_get_composite_flag (struct encoding * enc);
6895N/A struct encoding *
6895N/A get_encoding_by_alias PARAMS ((struct a2ps_job * job,
6895N/A char *string));
6895N/A@@ -70,6 +72,12 @@
6895N/A PARAMS ((struct a2ps_job * job,
6895N/A struct encoding * encoding,
6895N/A const char * font_name));
6895N/A+
6895N/A+
6895N/A+const char * encoding_resolve_composite_font
6895N/A+ PARAMS ((struct a2ps_job * job,
6895N/A+ struct encoding * encoding,
6895N/A+ const char * font_name));
6895N/A
6895N/A /*
6895N/A * Have a struct encoding determine the faces_wx
6895N/AIndex: b/lib/pair_ht.c
6895N/A===================================================================
6895N/A--- a/lib/pair_ht.c
6895N/A+++ b/lib/pair_ht.c
6895N/A@@ -49,6 +49,8 @@
6895N/A {
6895N/A char * key;
6895N/A char * value;
6895N/A+ float ratio;
6895N/A+ int wx;
6895N/A };
6895N/A
6895N/A /*
6895N/A@@ -165,6 +167,37 @@
6895N/A }
6895N/A
6895N/A /*
6895N/A+ * Add a pair, with your own allocation for them.
6895N/A+ * It KEY is yet used, override its value with VALUE
6895N/A+ */
6895N/A+void
6895N/A+pair_add2 (struct hash_table_s * table,
6895N/A+ const char * key, const char * value, int wx, float ratio)
6895N/A+{
6895N/A+ struct pair * item, token;
6895N/A+
6895N/A+ token.key = (char *) key;
6895N/A+ item = (struct pair *) hash_find_item (table, &token);
6895N/A+
6895N/A+ if (item) {
6895N/A+ if (item->value)
6895N/A+ free (item->value);
6895N/A+ } else {
6895N/A+ item = XMALLOC (struct pair, 1);
6895N/A+ item->key = xstrdup(key);
6895N/A+ item->wx = wx;
6895N/A+ item->ratio = ratio;
6895N/A+ }
6895N/A+
6895N/A+ if (value)
6895N/A+ item->value = xstrdup (value);
6895N/A+ else
6895N/A+ item->value = NULL;
6895N/A+
6895N/A+ hash_insert (table, item);
6895N/A+}
6895N/A+
6895N/A+/*
6895N/A * Remove a pair and free it.
6895N/A * It KEY is yet used, override its value with VALUE
6895N/A */
6895N/A@@ -201,6 +234,34 @@
6895N/A return NULL;
6895N/A }
6895N/A
6895N/A+int
6895N/A+pair_get_wx (struct hash_table_s * table, const char * key)
6895N/A+{
6895N/A+ struct pair * item, token;
6895N/A+
6895N/A+ token.key = (char *) key;
6895N/A+ item = (struct pair *) hash_find_item (table, &token);
6895N/A+
6895N/A+ if (item)
6895N/A+ return item->wx;
6895N/A+ else
6895N/A+ return -1;
6895N/A+}
6895N/A+
6895N/A+float
6895N/A+pair_get_ratio (struct hash_table_s * table, const char * key)
6895N/A+{
6895N/A+ struct pair * item, token;
6895N/A+
6895N/A+ token.key = (char *) key;
6895N/A+ item = (struct pair *) hash_find_item (table, &token);
6895N/A+
6895N/A+ if (item)
6895N/A+ return item->ratio;
6895N/A+ else
6895N/A+ return -1;
6895N/A+}
6895N/A+
6895N/A /*
6895N/A * Return the content of the hash table, ordered
6895N/A */
6895N/AIndex: b/lib/pair_ht.h
6895N/A===================================================================
6895N/A--- a/lib/pair_ht.h
6895N/A+++ b/lib/pair_ht.h
6895N/A@@ -56,6 +56,10 @@
6895N/A void pair_add PARAMS ((struct pair_htable * table,
6895N/A const char * key, const char * value));
6895N/A
6895N/A+void pair_add2 PARAMS ((struct pair_htable * table,
6895N/A+ const char * key, const char * value,
6895N/A+ int wx, float ratio));
6895N/A+
6895N/A /*
6895N/A * The key and value of the matching item will be free'd
6895N/A * (No problem if KEY matches nothing)
6895N/A@@ -68,6 +72,10 @@
6895N/A */
6895N/A char * pair_get PARAMS ((struct pair_htable * table,
6895N/A const char * key));
6895N/A+int pair_get_wx PARAMS ((struct pair_htable * table,
6895N/A+ const char * key));
6895N/A+float pair_get_ratio PARAMS ((struct pair_htable * table,
6895N/A+ const char * key));
6895N/A
6895N/A void pair_table_list_short PARAMS ((struct pair_htable * table,
6895N/A FILE * stream));
6895N/AIndex: b/lib/psgen.c
6895N/A===================================================================
6895N/A--- a/lib/psgen.c
6895N/A+++ b/lib/psgen.c
6895N/A@@ -875,6 +875,7 @@
6895N/A print:
6895N/A default:
6895N/A {
6895N/A+ static mb_flag= 0;
6895N/A uchar buf[256];
6895N/A int nchars;
6895N/A *buf = '\0';
6895N/A@@ -889,6 +890,29 @@
6895N/A job->status->face_declared = false;
6895N/A }
6895N/A
6895N/A+ if (c > 127 && encoding_get_composite_flag (job->encoding) &&
6895N/A+ job->status->face != Symbol) {
6895N/A+ if (mb_flag) {
6895N/A+ nchars = ps_escape_char (job, mb_flag, buf) +
6895N/A+ ps_escape_char (job, c, buf);
6895N/A+ job->status->wx += char_composite_WX(job, c);
6895N/A+ job->status->column += nchars;
6895N/A+ if (line_full) {
6895N/A+ if (job->folding) {
6895N/A+ fold_line (job, new_face);
6895N/A+ job->status->column = nchars*2;
6895N/A+ job->status->wx = char_composite_WX(job, c);
6895N/A+ } else {
6895N/A+ job->status->is_in_cut = true;
6895N/A+ return;
6895N/A+ }
6895N/A+ }
6895N/A+ mb_flag = 0;
6895N/A+ } else {
6895N/A+ mb_flag = c;
6895N/A+ return;
6895N/A+ }
6895N/A+ } else {
6895N/A nchars = ps_escape_char (job, c, buf);
6895N/A job->status->wx += char_WX (job, c);
6895N/A job->status->column += nchars;
6895N/A@@ -902,8 +926,9 @@
6895N/A return;
6895N/A }
6895N/A }
6895N/A+ }
6895N/A output (jdiv, "%s", buf);
6895N/A- job->status->chars++;
6895N/A+ job->status->chars+=nchars;
6895N/A }
6895N/A break;
6895N/A }
6895N/AIndex: b/ps/base.ps
6895N/A===================================================================
6895N/A--- a/ps/base.ps
6895N/A+++ b/ps/base.ps
6895N/A@@ -153,7 +153,11 @@
6895N/A % Return the y size of the current font
6895N/A % - => fontsize
6895N/A /currentfontsize {
6895N/A- currentfont /FontMatrix get 3 get 1000 mul
6895N/A+ currentfont /FontType get 0 eq {
6895N/A+ currentfont /FontMatrix get 3 get
6895N/A+ }{
6895N/A+ currentfont /FontMatrix get 3 get 1000 mul
6895N/A+ } ifelse
6895N/A } bind def
6895N/A
6895N/A % reencode the font
6895N/A@@ -200,6 +204,144 @@
6895N/A end
6895N/A } bind def
6895N/A
6895N/A+% composite fonts for ASCII-EUC mixed strings
6895N/A+% Version 1.2 1/31/1990
6895N/A+% Original Ken'ichi HANDA (handa@etl.go.jp)
6895N/A+% Modified Norio Katayama (katayama@rd.nacsis.ac.jp),1998
6895N/A+% Extend & Fix Koji Nakamaru (maru@on.cs.keio.ac.jp), 1999
6895N/A+% Anyone can freely copy, modify, distribute this program.
6895N/A+
6895N/A+/copyfont { % font-dic extra-entry-count copyfont font-dic
6895N/A+ 1 index maxlength add dict begin
6895N/A+ { 1 index /FID ne 2 index /UniqueID ne and
6895N/A+ {def} {pop pop} ifelse
6895N/A+ } forall
6895N/A+ currentdict
6895N/A+ end
6895N/A+} bind def
6895N/A+
6895N/A+/compositefont { % ASCIIFontName EUCFontName RomanScale RomanOffset Rot(T/F) compositefont font
6895N/A+ /RomanRotation exch def
6895N/A+ /RomanOffset exch def
6895N/A+ /RomanScale exch def
6895N/A+ userdict /fixeucfont_dict known not {
6895N/A+ userdict begin
6895N/A+ /fixeucfont_dict 2 dict begin
6895N/A+ /UpperByteEncoding [
6895N/A+ 16#00 1 16#20 { pop 0 } for
6895N/A+ 16#21 1 16#28 { 16#20 sub } for
6895N/A+ 16#29 1 16#2F { pop 0 } for
6895N/A+ 16#30 1 16#74 { 16#27 sub } for
6895N/A+ 16#75 1 16#FF { pop 0 } for
6895N/A+ ] def
6895N/A+ /LowerByteEncoding [
6895N/A+ 16#00 1 16#A0 { pop /.notdef } for
6895N/A+ 16#A1 1 16#FE { 16#80 sub 16 2 string cvrs
6895N/A+ (cXX) dup 1 4 -1 roll
6895N/A+ putinterval cvn } for
6895N/A+ /.notdef
6895N/A+ ] def
6895N/A+ currentdict
6895N/A+ end def
6895N/A+ end
6895N/A+ } if
6895N/A+ findfont dup /FontType get 0 eq {
6895N/A+ 14 dict begin
6895N/A+ %
6895N/A+ % 7+8 bit EUC font
6895N/A+ %
6895N/A+ 12 dict begin
6895N/A+ /EUCFont exch def
6895N/A+ /FontInfo (7+8 bit EUC font) readonly def
6895N/A+ /PaintType 0 def
6895N/A+ /FontType 0 def
6895N/A+ /FontMatrix matrix def
6895N/A+ % /FontName
6895N/A+ /Encoding fixeucfont_dict /UpperByteEncoding get def
6895N/A+ /FMapType 2 def
6895N/A+ EUCFont /WMode known
6895N/A+ { EUCFont /WMode get /WMode exch def }
6895N/A+ { /WMode 0 def } ifelse
6895N/A+ /FDepVector [
6895N/A+ EUCFont /FDepVector get 0 get
6895N/A+ [ 16#21 1 16#28 {} for 16#30 1 16#74 {} for ]
6895N/A+ {
6895N/A+ 13 dict begin
6895N/A+ /EUCFont EUCFont def
6895N/A+ /UpperByte exch 16#80 add def
6895N/A+ % /FontName
6895N/A+ /FontInfo (EUC lower byte font) readonly def
6895N/A+ /PaintType 0 def
6895N/A+ /FontType 3 def
6895N/A+ /FontMatrix matrix def
6895N/A+ /FontBBox {0 0 0 0} def
6895N/A+ /Encoding
6895N/A+ fixeucfont_dict /LowerByteEncoding get def
6895N/A+ % /UniqueID
6895N/A+ % /WMode
6895N/A+ /BuildChar {
6895N/A+ gsave
6895N/A+ exch dup /EUCFont get setfont
6895N/A+ /UpperByte get
6895N/A+ 2 string
6895N/A+ dup 0 4 -1 roll put
6895N/A+ dup 1 4 -1 roll put
6895N/A+ dup stringwidth setcharwidth
6895N/A+ 0 0 moveto show
6895N/A+ grestore
6895N/A+ } bind def
6895N/A+ currentdict
6895N/A+ end
6895N/A+ /lowerbytefont exch definefont
6895N/A+ } forall
6895N/A+ ] def
6895N/A+ currentdict
6895N/A+ end
6895N/A+ /eucfont exch definefont
6895N/A+ exch
6895N/A+ findfont 1 copyfont dup begin
6895N/A+ RomanRotation {
6895N/A+ /FontMatrix FontMatrix
6895N/A+ [ 0 RomanScale neg RomanScale 0 RomanOffset neg 0 ]
6895N/A+ matrix concatmatrix def
6895N/A+ }{
6895N/A+ /FontMatrix FontMatrix
6895N/A+ [ RomanScale 0 0 RomanScale 0 RomanOffset ] matrix concatmatrix
6895N/A+ def
6895N/A+ /CDevProc
6895N/A+ {pop pop pop pop 0 exch -1000 exch 2 div 880} def
6895N/A+ } ifelse
6895N/A+ end
6895N/A+ /asciifont exch definefont
6895N/A+ exch
6895N/A+ /FDepVector [ 4 2 roll ] def
6895N/A+ /FontType 0 def
6895N/A+ /WMode 0 def
6895N/A+ /FMapType 4 def
6895N/A+ /FontMatrix matrix def
6895N/A+ /Encoding [0 1] def
6895N/A+ /FontBBox {0 0 0 0} def
6895N/A+% /FontHeight 1.0 def % XXXX
6895N/A+ /FontHeight RomanScale 1.0 ge { RomanScale }{ 1.0 } ifelse def
6895N/A+ /Descent -0.3 def % XXXX
6895N/A+ currentdict
6895N/A+ end
6895N/A+ /tmpfont exch definefont
6895N/A+ pop
6895N/A+ /tmpfont findfont
6895N/A+ }{
6895N/A+ pop findfont 0 copyfont
6895N/A+ } ifelse
6895N/A+} def
6895N/A+
6895N/A+/slantfont { % FontName slant-degree slantfont font'
6895N/A+ exch findfont 1 copyfont begin
6895N/A+ [ 1 0 4 -1 roll 1 0 0 ] FontMatrix exch matrix concatmatrix
6895N/A+ /FontMatrix exch def
6895N/A+ currentdict
6895N/A+ end
6895N/A+} def
6895N/A+
6895N/A % Function print line number (<string> # -)
6895N/A /# {
6895N/A gsave