Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > bcad270e706b49dcd7d3b92dded440f2 > files > 4

ghostscript-8.15.2-9.12.el5_5.src.rpm

--- espgs-8.15.2/src/unixinst.mak.cjkv	2006-04-23 14:38:33.000000000 +0100
+++ espgs-8.15.2/src/unixinst.mak	2006-10-03 15:16:07.000000000 +0100
@@ -63,6 +63,7 @@
 	-mkdir -p $(install_prefix)$(gsdir)
 	-mkdir -p $(install_prefix)$(gsdatadir)
 	-mkdir -p $(install_prefix)$(gsdatadir)/lib
+	-mkdir -p $(install_prefix)$(gsdatadir)/lib/cjkv
 	$(SH) -c 'for f in \
 Fontmap Fontmap.GS cidfmap \
 FAPIcidfmap FAPIconfig FAPIfontmap xlatmap \
@@ -88,6 +89,10 @@
 	$(SH) -c 'for f in $(PSLIBDIR)/*.ppd $(PSLIBDIR)/*.rpd $(PSLIBDIR)/*.upp $(PSLIBDIR)/*.xbm $(PSLIBDIR)/*.xpm;\
 	do $(INSTALL_DATA) $$f $(install_prefix)$(gsdatadir)/lib ;\
 	done'
+# install cjkv patch
+	$(SH) -c 'for f in $(PSLIBDIR)/cjkv/*.ps ;\
+	do $(INSTALL_DATA) $$f $(install_prefix)$(gsdatadir)/lib/cjkv/ ;\
+	done'
 
 # install the default resource files
 # copy in every category (directory) but CVS
--- espgs-8.15.2/src/gstype42.c.cjkv	2005-09-22 22:31:58.000000000 +0100
+++ espgs-8.15.2/src/gstype42.c	2006-10-03 15:16:07.000000000 +0100
@@ -1,3 +1,11 @@
+/*
+ * Modified by AXE,Inc., BBR Inc. and Turbolinux Inc.
+ *   under the technical advice by suzuki toshiya (Hiroshima University)
+ * For questions, please send mail to espgs8-cjk@printing-japan.org
+ *
+ * (C) Copyright 2006 Center of the International Cooperation for
+ *     Computerization
+ */
 /* Copyright (C) 1996, 2000 Aladdin Enterprises.  All rights reserved.
   
   This software is provided AS-IS with no warranty, either express or
@@ -146,45 +154,6 @@
 	    pfont->data.metrics[1].offset = offset;
 	    pfont->data.metrics[1].length = (uint)u32(tab + 12);
 	}
-#if 1 /* XXXX */
-	else if (!memcmp(tab, "mort", 4)) {
-	    /* find vertical substitution */
-	    byte *mort;
-
-	    ACCESS(offset, 20, mort);	/* length not accurate */
-	    if ((uint)u32(mort) == 0x00010000) {
-		int nChains, i;
-		ulong Chainp = 8;
-
-		nChains = (int)u32(mort+4);
-		for (i=1; i <= nChains; i++) {
-		  int nSub, j;
-		  ulong Subp;
-
-		  nSub = U16(mort+Chainp+10);
-		  Subp = Chainp + U16(mort+Chainp+8)*12 + 12;
-		  for (j=1; j <= nSub; j++) {
-		     if ((U16(mort+Subp+2)&7) == 4) {
-			if ((U16(mort+Subp+8) == 6) &&
-			    (U16(mort+Subp+10) == 4)) {
-			  byte *ncgsv;
-			  int  cnt;
-			  cnt = U16(mort+Subp+12);
-			  ACCESS(offset+Subp+20, cnt*4, ncgsv);
-			  if (!pfont->data.mort_ncgsv_off) {
-			    pfont->data.mort_ncgsv_off = offset+Subp+20;
-			    pfont->data.mort_ncgsv_len = cnt*4;
-			  } else
-			    dlprintf("multiple ncgsv ignored.\n");
-			}
-		     }
-		     Subp += U16(mort+Subp);
-		  }
-		  Chainp += (int)u32(mort+Chainp+4);
-		}
-	    }
-	}
-#endif
     }
     loca_size >>= pfont->data.indexToLocFormat + 1;
     pfont->data.numGlyphs = (loca_size == 0 ? 0 : loca_size - 1);
@@ -206,20 +175,6 @@
 	pfont->FontBBox.q.x = S16(head_box + 4) / upem;
 	pfont->FontBBox.q.y = S16(head_box + 6) / upem;
     }
-#if 1 /* XXX */
-    if (! pfont->data.metrics[1].offset) {
-	/* no vhea/vmtx
-	 * shrink/expand the height to 1.0
- 	 */
-	float v;
-	v = - pfont->FontBBox.p.y + pfont->FontBBox.q.y;
-	    pfont->FontBBox.p.y /= v;
-	    pfont->FontBBox.q.y /= v;
-
-	    pfont->FontBBox.p.x /= v;
-	    pfont->FontBBox.q.x /= v;
-    }
-#endif
 #if NEW_TT_INTERPRETER
     pfont->data.warning_patented = false;
     pfont->data.warning_bad_instruction = false;
@@ -573,6 +528,49 @@
 			     origin.y + float2fixed(info.width[WMode].y));
 }
 
+/* Get glyph bounding box from font file */
+int
+gs_type42_glyph_fbbox(gs_font *font, uint glyph_index, gs_rect *pbbox)
+{
+    gs_font_type42 *const pfont = (gs_font_type42 *)font;
+    gs_glyph_data_t glyph_data;
+    double factor = 1.0 / pfont->data.unitsPerEm;
+    int code = 0;
+    const byte *gdata;
+
+    if ((code = pfont->data.get_outline(pfont, glyph_index, &glyph_data)) < 0) {
+	return code;		/* non-existent glyph */
+    }
+    if (glyph_data.bits.size == 0) {
+	return 1; /* notdef */
+    }
+    if (glyph_data.bits.size != 0 && S16(glyph_data.bits.data) == -1) {
+	/* This is a composite glyph. */
+	uint flags;
+	gs_matrix_fixed mat;
+
+	gdata = glyph_data.bits.data + 10;
+	memset(&mat, 0, sizeof(mat)); /* arbitrary */
+	do {
+	    uint comp_index = U16(gdata + 2);
+
+	    parse_component(&gdata, &flags, &mat, NULL, pfont, &mat);
+	    if (flags & TT_CG_USE_MY_METRICS) {
+		code = gs_type42_glyph_fbbox(pfont, comp_index,pbbox);
+		goto done;
+	    }
+	}
+	while (flags & TT_CG_MORE_COMPONENTS);
+    }
+    gdata = glyph_data.bits.data;
+    pbbox->p.x = S16(gdata+2)*factor;
+    pbbox->p.y = S16(gdata+4)*factor;
+    pbbox->q.x = S16(gdata+6)*factor;
+    pbbox->q.y = S16(gdata+8)*factor;
+done:
+    gs_glyph_data_free(&glyph_data, "gs_type42_enumerate_glyph");
+    return code;
+}
 /* Get glyph info by glyph index. */
 int
 gs_type42_glyph_info_by_gid(gs_font *font, gs_glyph glyph, const gs_matrix *pmat,
--- espgs-8.15.2/src/zchar42.c.cjkv	2005-01-19 04:08:41.000000000 +0000
+++ espgs-8.15.2/src/zchar42.c	2006-10-03 15:16:19.000000000 +0100
@@ -1,3 +1,12 @@
+/*
+ * Modified by AXE,Inc., BBR Inc. and Turbolinux Inc.
+ *   under the technical advice by suzuki toshiya (Hiroshima University)
+ * Based on bugfix by Masatake Yamato and Hideo Saito, 2001.
+ * For questions, please send mail to espgs8-cjk@printing-japan.org
+ *
+ * (C) Copyright 2006 Center of the International Cooperation for
+ *     Computerization
+ */
 /* Copyright (C) 1996, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
   
   This software is provided AS-IS with no warranty, either express or
@@ -44,7 +53,19 @@
 {   double sbw[4];
     double w[2];
     int present;
+#ifdef CJKV_BBOX
+    gs_rect bbox, *pbbox;
+    int code = gs_type42_glyph_fbbox(pbfont, glyph_index, &bbox);
+
+    if (code != 0) {
+	pbbox = &pbfont->FontBBox;
+    } else {
+	pbbox = &bbox;
+    }
+    code = zchar_get_metrics(pbfont, cnref, sbw);
+#else
     int code = zchar_get_metrics(pbfont, cnref, sbw);
+#endif /* CJKV_BBOX */
 
     if (code < 0)
 	return code;
@@ -75,7 +96,11 @@
 		}
 	    } else {
 		sbw[0] = sbw[2] / 2;
+#ifdef CJKV_BBOX
+		sbw[1] = pbbox->q.y - sbw42[1];
+#else
 		sbw[1] = (pbfont->FontBBox.q.y + pbfont->FontBBox.p.y - sbw42[3]) / 2;
+#endif /* CJKV_BBOX */
 		sbw[2] = sbw42[2];
 		sbw[3] = sbw42[3];
 	    }
@@ -87,7 +112,11 @@
     return zchar_set_cache(i_ctx_p, pbfont, cnref,
 			   (put_lsb && present == metricsSideBearingAndWidth ?
 			    sbw : NULL),
+#ifdef CJKV_BBOX
+			   w, pbbox,
+#else
 			   w, &pbfont->FontBBox,
+#endif /* CJKV_BBOX */
 			   cont, exec_cont,
 			   gs_rootfont(igs)->WMode ? sbw : NULL);
 }
--- espgs-8.15.2/src/zfcid1.c.cjkv	2005-09-22 22:31:58.000000000 +0100
+++ espgs-8.15.2/src/zfcid1.c	2006-10-03 15:16:07.000000000 +0100
@@ -35,10 +35,6 @@
 #include "stream.h"
 #include "files.h"
 
-#if 1 /* XXXX */
-private uint z11_find_repl_glyph(gs_font_cid2 *, uint);
-#endif
-
 /* ---------------- CIDFontType 1 (FontType 10) ---------------- */
 
 /* <string|name> <font_dict> .buildfont10 <string|name> <font> */
@@ -71,28 +67,6 @@
 
 /* ------ Accessing ------ */
 
-/* Replace a glyph with a vertical substitution */
-private uint
-z11_find_repl_glyph(gs_font_cid2 *pfont, uint glyph)
-{
-    int i;
-    const byte *data;
-
-    if (pfont->data.mort_ncgsv_off == 0)
-	return glyph;
-
-    if ((*pfont->data.string_proc)((gs_font_type42*)pfont,
-		(ulong)pfont->data.mort_ncgsv_off,
-		pfont->data.mort_ncgsv_len, &data) == 0) {
-	for (i=0; i < pfont->data.mort_ncgsv_len; i += 4) {
-	    if (((data[i]<<8)+data[i+1]) == glyph) {
-		return (uint)((data[i+2]<<8)+data[i+3]);
-	    }
-	}
-    }
-    return glyph;
-}
-
 /* Map a glyph CID to a TrueType glyph number using the CIDMap. */
 private int
 z11_CIDMap_proc(gs_font_cid2 *pfont, gs_glyph glyph)
@@ -133,43 +107,6 @@
     }
     for (i = 0; i < gdbytes; ++i)
 	gnum = (gnum << 8) + data[i];
-#if 1 /* XXXX */
-    if ( gnum != 0 &&
-	 pfont->cidata.common.CIDSystemInfo.Registry.size == 5 &&
-	!memcmp(pfont->cidata.common.CIDSystemInfo.Registry.data,"Adobe",5) &&
-	 pfont->cidata.common.CIDSystemInfo.Ordering.size == 6 &&
-	!memcmp(pfont->cidata.common.CIDSystemInfo.Ordering.data,"Japan1",6)) {
-	uint gnum0 = gnum;
-	  
-	/* ps string represented in EUC/ShiftJIS are mapped to CID string,
-	 * while certain characters (e.g. 0xa1c4) are mapped to different CID
-	 * (668 or 7897) depending on WMode(0 or 1).
-	 * But, when CID characters are mapped to ShiftJIS/Unicode to get
-	 * corresponding TTF glyphs, certain CID characters are mapped to
-	 * glyphs valid for horizonal writing
-	 * (there is no choice in ShiftJIS encoded TTF), using Resource/CMap
-	 *
-	 * Following code maps certain CID (for vertical writing chars)
-	 * to glyphs for vertical writing regardless of WMode!
-	 * This automatic mapping enables generating PDF of vertical writing.
-	 *
-	 * fixme: range correct?
-	 */
-	if (7887 <= cid && cid <= 7960) {
-	    /* substitute a glyph for vertical writing cid character */
-	    gnum = z11_find_repl_glyph(pfont, gnum);
-	}
-	if (gnum != gnum0) {
-	    if (gs_debug_c('J'))
-		dlprintf3("[J]z11_CIDMap_proc(): cid:%d -> %d -> %d\n",
-				cid, gnum0, gnum);
-	} else if (gs_debug_c('J')) {
-	    dlprintf2("[J]z11_CIDMap_proc(): cid:%d -> %d\n", cid, gnum);
-	}
-    } else if (gs_debug_c('J')) {
-	dlprintf2("[J]z11_CIDMap_proc(): cid:%d -> %d\n", cid, gnum);
-    }
-#endif
     return gnum;
 }
 
--- espgs-8.15.2/src/gxfont42.h.cjkv	2005-09-22 22:31:58.000000000 +0100
+++ espgs-8.15.2/src/gxfont42.h	2006-10-03 15:16:07.000000000 +0100
@@ -1,3 +1,11 @@
+/*
+ * Modified by AXE,Inc., BBR Inc. and Turbolinux Inc.
+ *   under the technical advice by suzuki toshiya (Hiroshima University)
+ * For questions, please send mail to espgs8-cjk@printing-japan.org
+ *
+ * (C) Copyright 2006 Center of the International Cooperation for
+ *     Computerization
+ */
 /* Copyright (C) 1996, 2000, 2001 Aladdin Enterprises.  All rights reserved.
   
   This software is provided AS-IS with no warranty, either express or
@@ -84,13 +92,6 @@
     bool warning_patented;
     bool warning_bad_instruction;
 #endif
-#if 1 /* XXXX */
-    /*
-     * to find out glyph substitution
-     */
-    uint mort_ncgsv_off;	/* vertical substition entry offset */
-    uint mort_ncgsv_len;	/* total number of bytes (4*#) */
-#endif
 };
 #define gs_font_type42_common\
     gs_font_base_common;\
@@ -137,6 +138,9 @@
 int gs_type42_get_outline_from_TT_file(gs_font_type42 * pfont, stream *s, uint glyph_index,
 		gs_glyph_data_t *pgd);
 
+/* Export the function get glypf bounding box from font data */
+int gs_type42_glyph_fbbox(gs_font *font, uint glyph_index, gs_rect *pbbox);
+
 /* Export the font procedures so they can be called from the interpreter. */
 font_proc_enumerate_glyph(gs_type42_enumerate_glyph);
 font_proc_glyph_info(gs_type42_glyph_info);
--- espgs-8.15.2/src/gdevpdtc.c.cjkv	2005-09-22 22:31:58.000000000 +0100
+++ espgs-8.15.2/src/gdevpdtc.c	2006-10-03 15:16:07.000000000 +0100
@@ -653,23 +653,13 @@
     if (pdsubf->u.cidfont.glyphshow_font_id != 0)
  	font0 = (gs_font_type0 *)gs_find_font_by_id(font->dir, 
  		    pdsubf->u.cidfont.glyphshow_font_id, &scaled_font->FontMatrix);
-#if 1 /* XXX */
-    if (font0 == NULL || font0->WMode != scaled_font->WMode) {
-  	code = gs_font_type0_from_cidfont(&font0, font, scaled_font->WMode,
- 					  &scale_matrix, font->memory);
-	if (code < 0)
-	    return code;
- 	pdsubf->u.cidfont.glyphshow_font_id = font0->id;
- 	font0->WMode = scaled_font->WMode; /* should not be here? */
-    }
-#else    if (font0 == NULL) {
+    if (font0 == NULL) {
   	code = gs_font_type0_from_cidfont(&font0, font, font->WMode,
  					  &scale_matrix, font->memory);
 	if (code < 0)
 	    return code;
  	pdsubf->u.cidfont.glyphshow_font_id = font0->id;
     }
-#endif
 
     /* Now handle the glyphshow as a show in the Type 0 font. */
 
--- espgs-8.15.2/src/zcfont.c.cjkv	2005-09-22 22:31:58.000000000 +0100
+++ espgs-8.15.2/src/zcfont.c	2006-10-03 15:16:07.000000000 +0100
@@ -127,10 +127,6 @@
 	    if (code < 0)
 		return code;
 	}
-#if 1 /* XXX */
-	if (scaled_font != root_font)
-	    scaled_font->WMode = root_font->WMode;	/* need for pdfwrite */
-#endif
 	push(3);
 	make_int(op - 2, gs_text_current_char(penum) & 0xff);
 	make_real(op - 1, wpt.x);
--- espgs-8.15.2/src/gdevpdtt.c.cjkv	2006-03-01 22:01:10.000000000 +0000
+++ espgs-8.15.2/src/gdevpdtt.c	2006-10-03 15:16:07.000000000 +0100
@@ -1802,11 +1802,6 @@
 		pwidths->Width.xy.y;
 	pwidths->Width.v.x = - pwidths->Width.xy.y / 2;
 	pwidths->Width.v.y = - pwidths->Width.xy.y;
-#if 1 /* XXX */
-	/* pwidths->Width.v.y *= 0.84; should use ascent/descent ratio */
-	pwidths->Width.v.y *=
-		cfont->FontBBox.q.y/(-cfont->FontBBox.p.y+cfont->FontBBox.q.y);
-#endif
     } else {
 	pwidths->Width.xy.x = pwidths->real_width.xy.x =
 		finfo.MissingWidth * scale_c;
@@ -1885,39 +1880,8 @@
 
 	    if (get_missing_width(cfont, 0, scale_c, &widths1) < 0)
 		v.x = 0;
-#if 1 /* XXX */	/* Adobe-Japan specific */
-#define in_cid(s,e,cid,g) \
-    ((gs_min_cid_glyph + cid) <= g && g <= (gs_min_cid_glyph + cid + e - s))
-#define Roman(g) in_cid(0x20, 0x7e, 231, g)
-#define Hankaku(g) \
-    (in_cid(0x20, 0x5f, 231, g) || in_cid(0x60, 0x60, 231, g) || \
-     in_cid(0x61, 0x7e, 296, g) || in_cid(0x81, 0x85, 327, g) || \
-     in_cid(0x86, 0x8f, 516, g) || in_cid(0x90, 0x90, 342, g) || \
-     in_cid(0x91, 0x9f, 526, g) || in_cid(0xa1, 0xdf, 327, g) || \
-     in_cid(0xe0, 0xfd, 541, g) || in_cid(0xfe, 0xff, 388, g))
-#define Hiragana(g) \
-    (in_cid(0x20, 0x20, 515, g) || in_cid(0x21, 0x25, 327, g) || \
-     in_cid(0x26, 0x2f, 516, g) || in_cid(0x30, 0x30, 342, g) || \
-     in_cid(0x31, 0x5d, 526, g) || in_cid(0x5e, 0x5f, 388, g) || \
-     in_cid(0x60, 0x62, 571, g) || in_cid(0x66, 0x7e, 574, g))
-
-#define adobe_japan_ascii(fp, gly) \
-    fp->FontType == ft_CID_TrueType && \
-    ((gs_font_cid2*)fp)->cidata.common.CIDSystemInfo.Registry.size == 5 && \
-    !memcmp(((gs_font_cid2*)fp)->cidata.common.CIDSystemInfo.Registry.data,"Adobe",5) && \
-     ((gs_font_cid2*)fp)->cidata.common.CIDSystemInfo.Ordering.size == 6 && \
-    !memcmp(((gs_font_cid2*)fp)->cidata.common.CIDSystemInfo.Ordering.data,"Japan1",6) && \
-    (Roman(gly) || Hankaku(gly) || Hiragana(gly))
-
-	    else {
-		v.x = widths1.Width.w / 2;
-		if (adobe_japan_ascii(ofont,glyph))
-		    v.x /= 2;
-	    }
-#else
 	    else
 		v.x = widths1.Width.w / 2;
-#endif
 	} else
 	    v.x = pwidths->Width.v.x;
     } else if (code < 0)
@@ -1939,21 +1903,6 @@
 		
 		if (get_missing_width(cfont, 0, scale_c, &widths1) < 0)
 		    v.x = 0;
-#if 1 /* XXX */	/* Adobe-Japan specific */
-		else {
-		    v.x = widths1.Width.w / 2;
-		    if (adobe_japan_ascii(ofont,glyph))
-			v.x /= 2;
-		}
-#undef in_cid
-#undef Roman
-#undef Hankaku
-#undef Hiragana
-#undef adobe_japan_ascii
-#else
-		else
-		    v.x = widths1.Width.w / 2;
-#endif
 	    }
 	} else {
 	    if (info.members  & (GLYPH_INFO_VVECTOR0 << wmode)) {
--- espgs-8.15.2/src/zchar1.c.cjkv	2005-02-16 21:21:49.000000000 +0000
+++ espgs-8.15.2/src/zchar1.c	2006-10-03 15:16:07.000000000 +0100
@@ -1,3 +1,12 @@
+/*
+ * Modified by AXE,Inc., BBR Inc. and Turbolinux Inc.
+ *   under the technical advice by suzuki toshiya (Hiroshima University)
+ * Based on bugfix by Hideo Saito, 2001.
+ * For questions, please send mail to espgs8-cjk@printing-japan.org
+ *
+ * (C) Copyright 2006 Center of the International Cooperation for
+ *     Computerization
+ */
 /* Copyright (C) 1993, 2000, 2002 Aladdin Enterprises.  All rights reserved.
   
   This software is provided AS-IS with no warranty, either express or
@@ -240,6 +249,7 @@
 	cxs.sbw[2] = 0;
 	cxs.sbw[3] = -penum->FontBBox_as_Metrics2.x; /* Sic! */
 	cxs.use_FontBBox_as_Metrics2 = true;
+	cxs.present = metricsSideBearingAndWidth;
     }
     /* Establish a current point. */
     code = gs_moveto(igs, 0.0, 0.0);
@@ -272,7 +282,8 @@
 	const ref *opstr = op;
 	ref other_subr;
 
-	if (cxs.present == metricsSideBearingAndWidth) {
+	if (cxs.present == metricsSideBearingAndWidth
+	    && !cxs.use_FontBBox_as_Metrics2) {
 	    gs_point sbpt;
 
 	    sbpt.x = cxs.sbw[0], sbpt.y = cxs.sbw[1];
@@ -349,11 +360,48 @@
     } else {
 	/* We have the width and bounding box: */
 	/* set up the cache device now. */
+        double w[2];
+        w[0] = pcxs->sbw[2], w[1] = pcxs->sbw[3];
+      
+	if (pcxs->use_FontBBox_as_Metrics2) {
+	   /* In this case, we have to calculate width for WMode=0. 
+	      pcxs->sbw[2, 3] is width for WMode=1.
+	      Normally, the width for WMode=0 is not used in WMode=1 
+	      rendering. However, if CDevProc is defined, 
+	      the width for WMode=0 is used. 
+	      Do the same as the case pcxs->present == metricsNone */
+	     double sbw[4];
+	     ref cnref;
+	     ref other_subr;
+	     int code;
+	     
+	    /* Since an OtherSubr callout might change osp, */
+	    /* save the character name now. */
+	    ref_assign(&cnref, op - 1);
+	    code = type1_continue_dispatch(i_ctx_p, pcxs, op, &other_subr, 4);
+	    op = osp;		/* OtherSubrs might change it */
+	    switch (code) {
+ 	     default:		/* code < 0 or done, error */
+		 return ((code < 0 ? code :
+			 gs_note_error(e_invalidfont)));
+	    case type1_result_callothersubr:	/* unknown OtherSubr */
+		return type1_call_OtherSubr(i_ctx_p, pcxs,
+					    bbox_getsbw_continue,
+					    &other_subr);
+	    case type1_result_sbw:	/* [h]sbw, done */
+		break;
+	    }
+	    type1_cis_get_metrics(pcis, sbw);
+	    w[0] = sbw[2], w[1] = sbw[3];
+	    /* Now actual width is available, I can calculate much 
+	       better side bearing for WMode 1 from the width. */
+	    pcxs->sbw[0] = w[0] / 2;
+	}
  	return zchar_set_cache(i_ctx_p, pbfont, op - 1,
 			       (pcxs->present == metricsSideBearingAndWidth
 			        && !pcxs->use_FontBBox_as_Metrics2 ?
 			        pcxs->sbw : NULL),
-			       pcxs->sbw + 2,
+			       w,
 			       &pcxs->char_bbox,
 			       cont, exec_cont, 
 			       (pcxs->use_FontBBox_as_Metrics2 ? pcxs->sbw : NULL));
@@ -581,7 +629,7 @@
     code = type1_exec_init(&cxs.cis, penum, igs, pfont1);
     if (code < 0)
 	return code;
-    cxs.char_bbox = pfont1->FontBBox;
+    cxs.char_bbox = bbox;
     code = type1exec_bbox(i_ctx_p, &cxs, pfont, exec_cont);
     return code;
 }
@@ -795,6 +843,7 @@
     int code;
     gs_text_enum_t *penum = op_show_find(i_ctx_p);
     gs_font *pfont;
+    double w[2];
 
     if ((code = gs_pathbbox(igs, &pcxs->char_bbox)) < 0 ||
 	(code = font_param(op - 3, &pfont)) < 0
@@ -807,13 +856,24 @@
 	gs_font_type1 *const pfont1 = (gs_font_type1 *) pfont;
 	op_proc_t cont, exec_cont = 0;
 
-	if (pcxs->present == metricsNone) {
+	if (pcxs->present == metricsNone
+	    || pcxs->use_FontBBox_as_Metrics2) {
 	    gs_point endpt;
 
 	    if ((code = gs_currentpoint(igs, &endpt)) < 0)
 		return code;
-	    pcxs->sbw[2] = endpt.x, pcxs->sbw[3] = endpt.y;
+	    /* We will not use sbw[3, 4]. 
+	       If pcxs->use_FontBBox_as_Metrics2 is true,
+	       sbw[3, 4] are used as arguments(W1x, W1y) of setcachedevice2. 
+	       We will use w[0, 1] as W0x and W0y of setcachedevice2.
+	       W0 and W1 is differrent parameters. Don't confuse. */
+	    w[0] = endpt.x, w[1] = endpt.y;
 	    pcxs->present = metricsSideBearingAndWidth;
+	    if (pcxs->use_FontBBox_as_Metrics2) {
+	      /* Now actual width is available, I can calculate much 
+		 better side bearing for WMode 1 from the width. */
+	      pcxs->sbw[0] = w[0] / 2;
+	    }
 	}
 	/*
 	 * We only need to rebuild the path from scratch if we might
@@ -830,7 +890,7 @@
 	} else {
 	    cont = (pbfont->PaintType == 0 ? nobbox_fill : nobbox_stroke), exec_cont = 0;
 	    code = zchar_set_cache(i_ctx_p, pbfont, op - 1, NULL,
-				   pcxs->sbw + 2,
+				    w,
 				   &pcxs->char_bbox,
 				   cont, &exec_cont,
 				   (pcxs->use_FontBBox_as_Metrics2 ? pcxs->sbw : NULL));
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/cjkcidcm.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,455 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Taiji Yamada, Masatake Yamato, Hideyuki Suzuki and suzuki toshiya.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+true setglobal
+
+[
+   /CJKV_DEBUG_CIDCM
+   /NOCIDFONTMAP
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+% -------------------------------------------------------------------------------
+% taken from gs7.05/lib/gs_cidcm.ps
+
+25 dict begin
+
+  /.prs_dict currentdict def
+  /.prs_empty 0 dict readonly def
+  /enable_cache true def
+  /path_buffer 8192 string def
+  /name_buffer 1024 string def
+  /minus (-) 0 get def             % character code constant for '-'
+  /period (.) 0 get def            % character code constant for '.'
+  /CMap 10 dict def                % CSI cache for CMaps
+  /CIDFont 10 dict def             % CSI cache for CIDFonts
+  /enable_cache true def           % set false to disable cache
+  /.prsFile 0 def                   % file to prescan
+  /.prsResult 0 def                 % result of prescan
+  /.prsDictCount 0 def              % save the dictionary stack depth
+
+
+  /.cjkv_StopIfCSIDefined {   % - StopIfCSIDefined -
+    CJKV_DEBUG_CIDCM { (.cjkv_StopIfCSIDefined\n) print flush } if
+  
+    % Check if the dictionary stack contains a dictionary containing /CIDSystemInfo.
+    % The search is limited to the top .prsDictCount dictionaries in the stack.
+    % If so, retrieve the CSI, and execute stop to terminate the pre-scanning of the file.
+    % Otherwise, do nothing, so the pre-scanning continues.
+  
+    countdictstack //.prs_dict /.prsDictCount get sub dup {
+      currentdict /CIDSystemInfo .knownget {
+        //.prs_dict exch /.prsResult exch put
+        stop
+      } if
+      currentdict exch end
+    } repeat {
+      begin
+    } repeat
+  } bind def
+  
+  /.cjkv_PrescanFile {     % - PrescanFile -
+    CJKV_DEBUG_CIDCM { (.cjkv_PrescanFile\n) print flush } if
+    { //.prs_dict /.prsFile get token {
+        dup type                          % token type
+        dup /nametype eq exch /operatortype eq or {
+          dup xcheck {
+            exec
+            //.cjkv_StopIfCSIDefined exec
+          } if
+        } if
+      } {
+        stop
+      } ifelse
+    } loop
+  } bind odef
+  
+  /.cjkv_GetCIDSystemInfoFromFile { % <file> GetCIDSystemInfoFromFile <CSI>
+    CJKV_DEBUG_CIDCM { (.cjkv_GetCIDSystemInfoFromFile\n) print flush } if
+    //.prs_dict begin
+    /.prsFile exch def
+    /.prsResult //.prs_empty def
+    /.prsDictCount countdictstack def
+    { //.cjkv_PrescanFile } stopped pop
+    //.prs_dict /.prsResult get
+    end
+  } bind def
+
+
+  /.cjkv_GetCIDSystemInfo {     % <InstName> <CatName> GetCIDSystemInfo <CSI>
+    CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: ) print 1 index =only ( in ) print dup == flush } if
+    2 copy resourcestatus {
+      CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource status OK\n) print } if
+      pop 2 lt {
+        CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource status < 2\n) print } if
+        findresource /CIDSystemInfo .knownget not { //.prs_empty } if
+      } {
+        CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource status >= 2\n) print } if
+        dup //.prs_dict exch get dup 3 index known //enable_cache and {
+          CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource cached\n) print } if
+          exch pop exch get
+        } {
+          CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource not-cached\n) print } if
+          3 1 roll /Category findresource begin dup //path_buffer ResourceFileName
+          end currentglobal exch true setglobal mark exch {
+            CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo->.cjkv_GetCIDSystemInfoFromFile\n) print } if
+            (r) file //.cjkv_GetCIDSystemInfoFromFile exec
+          } stopped
+          {
+            cleartomark 1 index dup
+            CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo->.CIDFontmapKnownget START\n) print } if
+            /CIDFont /Category findresource /.cjkv_CIDFontmapKnownget get exec
+            CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo->.CIDFontmapKnownget EXECED\n) print } if
+            {
+              CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo [knownget OK]\n) print } if
+              true setglobal 1 index 3 1 roll
+              CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo->.cjkv_CIDFontmapRunHandler\n) print } if
+              /CIDFont /Category findresource /.cjkv_CIDFontmapRunHandler get exec
+              CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo<-.cjkv_CIDFontmapRunHandler\n) print } if
+              /CIDFont findresource /CIDSystemInfo get
+            } {
+              CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo [knownget FAILED]\n) print } if
+              pop //.prs_empty
+            } ifelse
+          } {
+            CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo [not stopped]\n) print } if
+            exch pop
+          } ifelse
+          exch setglobal dup 4 1 roll put
+        } ifelse
+      } ifelse
+    } {
+      CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo: resource status FAILED\n) print } if
+      pop pop //.prs_empty
+    } ifelse
+    CJKV_DEBUG_CIDCM { (*** .cjkv_GetCIDSystemInfo finished\n) print flush } if
+  } bind def
+
+  /GetCIDSystemInfo {
+    .cjkv_GetCIDSystemInfo
+  } bind def
+
+  % -------------------------------------------------------------------------------
+  /orig_font_resourcestatus /Generic /Category findresource /ResourceStatus get bind def
+  /orig_font_resourceforall /Generic /Category findresource /ResourceForAll get bind def
+  /orig_font_findresource   /Font    /Category findresource /FindResource   get bind def
+
+  /BindAux {   % <proc> BindAux <proc>
+    0 exec
+  } bind def
+  
+  /EnumerateFontNames {
+    end
+    {
+      0 1 2 {
+        en_local_dict exch /status exch put
+        Fonts {
+          en_local_dict /status get eq {
+            scr cvs
+            proc exec
+          } {
+            pop
+          } ifelse
+        } forall
+      } for
+    } stopped
+    Category begin
+    { stop } if
+  } bind def
+  
+  /Bind {
+    dup length array copy
+    dup length 1 sub -1 0 {
+      2 copy get
+      dup dup type /arraytype eq exch xcheck and {
+        //BindAux exec
+        2 index 3 1 roll put
+      } {
+        dup dup type /nametype eq exch xcheck and {
+          currentdict exch .knownget {
+            2 index 3 1 roll put
+          } {
+            pop
+          } ifelse
+        } {
+          pop pop
+        } ifelse
+      } ifelse
+    } for
+    cvx
+  } bind def
+  
+  //BindAux 0 //Bind put
+
+  CJKV_DEBUG_CIDCM { (*** Font Enumurator utility definition OK\n) print flush } if
+
+  % ---------------------------------------------------------------------------------
+
+  /.cjkv_ComposeName {
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ComposeName\n) print flush } if
+    dup dup 5 2 roll 3 2 roll exch cvs length dup 4 -1 roll exch //minus put 1 add dup
+    3 index dup length 2 index sub 3 2 roll exch getinterval 3 2 roll exch cvs length
+    add 0 exch getinterval
+  } bind def
+
+  /.cjkv_IsCompatibleCSI {
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsCompatibleCSI\n) print flush } if
+    exch
+    { dup type /arraytype eq {
+        dup length 1 ne { pop pop false exit } if
+        0 get
+      } if
+      dup type /dicttype ne { pop pop false exit } if
+      exch
+      dup type /dicttype ne { pop pop false exit } if
+      true
+      [/Registry /Ordering] {
+        2 index 1 index .knownget not { 1234567 } if
+        exch
+        4 index exch .knownget not { 7654321 } if
+        eq and
+      } forall
+      exch pop exch pop
+      exit
+    } loop
+  } bind def
+
+  /.cjkv_IsComposedOK {
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK ENTER with: ) print 1 index =only ( ) print dup == flush } if
+    exch
+    /CIDFont
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK->.cjkv_GetCIDSystemInfo for CIDFont:) print 1 index == flush } if
+    .cjkv_GetCIDSystemInfo
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK<-.cjkv_GetCIDSystemInfo\n) print flush } if
+    dup type /dicttype eq {
+      dup length 0 ne {
+        exch /CMap
+        CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK->.cjkv_GetCIDSystemInfo for CMap:) print 1 index == flush } if
+        .cjkv_GetCIDSystemInfo
+        CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK<-.cjkv_GetCIDSystemInfo\n) print flush } if
+        CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK->.cjkv_IsCompatibleCSI\n) print flush } if
+        .cjkv_IsCompatibleCSI
+        CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK<-.cjkv_IsCompatibleCSI\n) print flush } if
+      } {
+        pop pop false
+      } ifelse
+    } {
+      pop pop false
+    } ifelse
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedOK EXIT with ) print dup == flush } if
+  } bind def
+  
+  /.cjkv_IsComposedFont {
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedFont START: ) print 3 index =only ( ) print 2 index =only ( ) print 1 index =only ( ) print dup ==  flush } if
+    dup type /stringtype ne {
+      //name_buffer cvs
+    } if
+    {
+      dup length 2 sub -1 1 {
+        2 copy get dup //minus eq exch //period eq or {
+          2 copy 2 copy
+          2 copy get //minus eq {
+            2 copy 1 sub get //minus eq {
+              1 sub
+            } if
+          } if
+          0 exch getinterval cvn 3 1 roll 1 add dup 5 index length exch sub getinterval cvn
+          2 copy
+          CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedFont->.cjkv_IsComposedOK\n) print flush } if
+          .cjkv_IsComposedOK {
+            4 2 roll pop pop stop
+          } if
+          pop pop pop
+        } {
+          pop
+        } ifelse
+      } for
+      pop
+    } stopped
+    CJKV_DEBUG_CIDCM { (*** .cjkv_IsComposedFont END:\n) print pstack (--bottom--\n) print flush } if
+  } bind def
+
+  CJKV_DEBUG_CIDCM { (*** CIDFont-CMap font utility definition OK\n) print flush } if
+
+  % -------------------------------------------------------------------------------
+
+  /.cjkv_ResourceStatus {  % <InstName> ResourceStatus <nStatus> <nSize> true
+    	                   % <InstName> ResourceStatus false
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus start\n) print pstack (  ---bottom--\n) print flush } if
+    dup
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus->orig_font_resourcestatus [for precomposed CIDFont-CMap resource]\n) print flush } if
+    orig_font_resourcestatus {
+      CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus->orig_font_resourcestatus OK, exit\n) print flush } if
+      3 2 roll pop true
+    } {
+      CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus->orig_font_resourcestatus FAILED, check uncomposed composite font\n) print flush } if
+      CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus->.cjkv_IsComposedFont\n) print flush } if
+      .cjkv_IsComposedFont {
+        CJKV_DEBUG_CIDCM { (*** looks composite font, check CMap\n) print flush } if
+        /CMap CJKV_DEBUG_CIDCM { (---top---\n) print pstack (---bottom---\n) print flush } if resourcestatus {
+          CJKV_DEBUG_CIDCM { (*** CMap OK, check CIDFont\n) print flush } if
+          exch pop exch /CIDFont resourcestatus {
+            CJKV_DEBUG_CIDCM { (*** exist, finally check status/size\n) print flush } if
+            exch pop dup 0 ge {
+              CJKV_DEBUG_CIDCM { (*** check status/size OK\n) print flush } if
+              exch dup 0 ge {
+                add
+              } {
+                exch pop
+              } ifelse
+            } {
+              CJKV_DEBUG_CIDCM { (*** check status/size FAILED\n) print flush } if
+              pop
+            } ifelse
+            2 exch true
+          } {
+            CJKV_DEBUG_CIDCM { (*** inexist CIDFont\n) print flush } if
+            pop pop pop false
+          } ifelse
+        } {
+          CJKV_DEBUG_CIDCM { (*** inexist CMap\n) print flush } if
+          pop pop pop false
+        } ifelse
+      } {
+        CJKV_DEBUG_CIDCM { (*** not composite font\n) print flush } if
+        false
+      } ifelse
+    } ifelse
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceStatus finished\n) print pstack (  ---bottom--\n) print flush } if
+  } bind def
+
+  /ResourceStatus {
+    CJKV_DEBUG_CIDCM { (*** STUB: ResourceStatus\n) print flush } if
+    .cjkv_ResourceStatus
+  } bind def
+
+  % -------------------------------------------------------------------------------
+  
+  /.cjkv_ResourceForAll { % <template> <proc> <scratch> ResourceForAll -
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceForAll\n) print flush } if
+    currentglobal false setglobal
+    20 dict 20 dict 20 dict
+    4 -1 roll setglobal
+    5 index [ 2 index {exch cvn dup put} aload pop ] cvx 5 index orig_font_resourceforall
+    (*)     [ 3 index {exch cvn dup put} aload pop ] cvx 5 index /CMap resourceforall
+    (*)     [ 4 index {exch cvn dup put} aload pop ] cvx 5 index /CIDFont resourceforall
+    dup {
+      //.cjkv_ResourceStatus exec {
+        pop 2 index 3 1 roll put
+      } {
+        pop
+      } ifelse
+    } forall
+  
+    3 2 roll  {
+      3 index {
+        3 1 roll 6 index .cjkv_ComposeName dup 8 index .stringmatch {
+          cvn dup 4 index exch known {
+            pop pop
+          } {
+            2 index 4 2 roll .cjkv_IsComposedOK {
+              exch 2 index exch 2 put
+            } {
+              exch pop
+            } ifelse
+          } ifelse
+        } {
+          pop pop
+        } ifelse
+        dup
+      } forall
+      pop pop
+    } forall
+    exch pop
+  
+    currentdict
+    6 dict begin % the temporary dictionary
+      /Category exch def
+      /Fonts exch def
+      /scr exch def
+      /proc exch def
+      /en_local_dict currentdict def
+      //EnumerateFontNames //Bind exec
+      /status 0 def
+    end
+    exch pop
+  
+    exec
+    CJKV_DEBUG_CIDCM { (*** .cjkv_ResourceForAll finished\n) print flush } if
+  } bind def
+
+  /ResourceForAll {
+    CJKV_DEBUG_CIDCM { (*** STUB: ResourceStatus\n) print flush } if
+    .cjkv_ResourceForAll
+  } bind def
+
+  CJKV_DEBUG_CIDCM { (*** ResourceForAll definition OK\n) print flush } if
+
+  % -------------------------------------------------------------------------------
+
+  /.cjkv_FindResource {
+    CJKV_DEBUG_CIDCM { (*** .cjkv_FindResource\n) print flush } if
+    dup //.cjkv_ResourceStatus exec {
+      pop pop
+      CJKV_DEBUG_CIDCM { (*** .cjkv_FindResource->orig_font_findresource #1\n) print flush } if
+      orig_font_findresource
+    } {
+      dup
+        CJKV_DEBUG_CIDCM { (*** .cjkv_FindResource->.cjkv_IsComposedFont\n) print flush } if
+        //.cjkv_IsComposedFont exec {
+        exch [ exch ] composefont
+      } {
+        CJKV_DEBUG_CIDCM { (*** .cjkv_FindResource->orig_font_findresource #2\n) print flush } if
+        orig_font_findresource
+      } ifelse
+    } ifelse
+    CJKV_DEBUG_CIDCM { (*** .cjkv_FindResource finished\n) print flush } if
+  } bind def
+ 
+  /FindResource {
+    CJKV_DEBUG_CIDCM { (*** STUB: FindResource\n) print flush } if
+    .cjkv_FindResource
+  } bind def
+
+  % -------------------------------------------------------------------------------
+
+currentdict end
+% /Generic /Category findresource dup length 25 add dict .copydict copy
+/Font /Category findresource dup length 25 add dict .copydict copy
+/Font exch /Category
+defineresource pop
+false setglobal
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/tt42util.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,482 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Taiji Yamada, Hideyuki Suzuki, Masatake Yamato and suzuki toshiya.
+%   Enhancements by Akira Tagoh and Taiji Yamada, 2005.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+
+[
+   /CJKV_DEBUG_TT42
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+/_cjkv_type42_tmp 10 dict def
+
+/_cjkv_type42_util 15 dict dup begin
+
+  % <tab> .cjkv_printtab -
+  /.cjkv_printtab {
+    CJKV_DEBUG_TT42 { (.cjkv_printtab\n) print flush } if
+    dup 0 4 getinterval print ( ) print
+    dup 8 .cjkv_getu32 =only ( ) print
+    12 .cjkv_getu32 =
+  } bind def
+  
+  % <file> .cjkv_loadttfonttables -
+  % <file> <fontindex> .cjkv_loadttfonttables - % extention by hideyuki
+  % Pushes .cjkv_loadttfontdict & scratch dict on d-stack.
+  % Defines f, offsets, tables, tabdict, tabs.
+  /.cjkv_loadttfonttables {
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables start\n) print flush } if
+    _cjkv_base_util begin
+    40 dict begin
+    dup type /integertype eq % extention by hideyuki
+    { 1 sub } { 0 } ifelse /findex exch def
+    /f exch def
+    /offsets f 12 string readstring pop def
+  
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables init #1 is ok\n) print flush } if
+    % TrueType Collection File support
+    % Jan 11 2000: Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+    % Feb 10 2001: suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+    offsets 0 4 getinterval (ttcf) eq {
+      [ 1 1 offsets 8 .cjkv_getu32 { pop f 4 string readstring pop 0 .cjkv_getu32} for ]
+      dup findex get dup /ttcheader exch def exch length 4 mul 12 add sub
+      %dup 0 gt { string f exch readstring pop } if pop
+      f fileposition add f exch setfileposition
+      % the previous line is for very large ttcf, hacked by suzuki toshiya
+      /offsets f 12 string readstring pop def
+    } { /ttcheader 0 def } ifelse
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables init #2 is ok\n) print flush } if
+  
+    /tables f offsets 4 .cjkv_getu16 16 mul string readstring pop def
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables tables def ok\n) print flush } if
+    /tabdict tables length 16 idiv dict def
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables tabdict def ok\n) print flush } if
+  	% tabs = tables we want to keep, sorted by file position.
+    /tabs [ 0 16 tables length 1 sub {
+      tables exch 16 getinterval
+      CJKV_DEBUG_TT42 { dup _cjkv_type42_util /.cjkv_printtab get exec } if
+      dup 0 4 getinterval _cjkv_readtables 1 index known {
+        tabdict exch 2 index put
+      } {
+        pop pop
+      } ifelse
+    } for ] {
+      exch 8 .cjkv_getu32 exch 8 .cjkv_getu32 lt
+    } .cjkv_sort def
+  	% In certain malformed TrueType fonts, tables overlap.
+  	% Truncate tables if necessary.
+    0 1 tabs length 2 sub {
+      dup tabs exch get exch 1 add tabs exch get
+      1 index 8 .cjkv_getu32 2 index 12 .cjkv_getu32 add
+      1 index 8 .cjkv_getu32 gt {
+        (**** Warning: ) print 1 index 0 4 getinterval print
+        ( overlaps ) print dup 0 4 getinterval print
+        (, truncating.) = flush
+        dup 8 .cjkv_getu32 2 index 8 .cjkv_getu32 sub
+        2 index 12 3 -1 roll .cjkv_putu32
+      } if pop pop
+    } for
+    CJKV_DEBUG_TT42 { (*** .cjkv_loadttfonttables finished \n) print flush } if
+  } bind def
+  
+  % - .cjkv_readttdata -
+  % Read data.  Updates offsets, tabs; stores data in tabdict.
+  /.cjkv_readttdata {
+    CJKV_DEBUG_TT42 { (.cjkv_readttdata\n) print flush } if
+  
+    % TrueType Collection File support
+    % Jan 11 2000: Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+    % /fpos offsets length tables length add def
+    /fpos ttcheader offsets length tables length add add def
+    /sfpos offsets length tabs length 16 mul add def
+    offsets 4 tabs length .cjkv_putu16
+    tabs {
+      dup 0 4 getinterval /tname exch def
+      dup 8 .cjkv_getu32 /tpos exch def
+      dup 12 .cjkv_getu32 /tlen exch def
+      8 sfpos .cjkv_putu32
+  	% Skip data between the end of the previous table and
+  	% the beginning of this one, if any.
+      tpos fpos gt {
+        f tpos fpos sub () /SubFileDecode filter dup flushfile closefile
+        /fpos tpos def
+      } if
+      f tlen _cjkv_readtables tname get exec
+      tabdict tname 3 -1 roll put
+      /fpos fpos tlen add def
+  	% Round up the table length to an even value.
+      /sfpos sfpos tlen dup 1 and add add def
+    } forall
+  } bind def
+  
+  % Find the string in a list of strings that includes a given index.
+  % <strings> <index> .findseg <string> <index'>
+  /.cjkv_findseg {
+    CJKV_DEBUG_TT42 { (.cjkv_findseg\n) print flush } if
+    exch {
+      dup length 2 index gt { exch exit } if
+      length sub
+    } forall
+  } bind def
+  
+  % - .cjkv_makesfnts -
+  % Defines checksum, getloca, head, locatable, numloca, post, sfnts, upem
+  /.cjkv_makesfnts {
+    CJKV_DEBUG_TT42 { (.cjkv_makesfnts\n) print flush } if
+    _cjkv_type42_util /.cjkv_readttdata get exec
+    /head tabdict /head get def
+    /locatable tabdict /loca get def
+    /post tabdict /post .knownget not { null } if def
+    /numloca
+      locatable dup type /stringtype eq
+       { length }
+       { 0 exch { length add } forall }
+      ifelse      % no def yet
+    locatable type /stringtype eq {
+      _cjkv_type42_tmp /.indexloca {} put
+    } {
+      _cjkv_type42_tmp /.indexloca _cjkv_type42_util /.cjkv_findseg get put
+    } ifelse
+    head 50 .cjkv_getu16 0 ne {
+      _cjkv_type42_tmp /getloca {
+        2 bitshift locatable exch _cjkv_type42_tmp /.indexloca get exec .cjkv_getu32
+      } put
+      4 idiv 1 sub
+    } {
+      _cjkv_type42_tmp /getloca {
+        dup add locatable exch _cjkv_type42_tmp /.indexloca get exec .cjkv_getu16 dup add
+      } put
+      2 idiv 1 sub
+    } ifelse def          % numloca
+          % If necessary, re-partition the glyfs.
+    tabdict /glyf get dup type /stringtype ne {
+      _cjkv_type42_util /.cjkv_dividesfnts get exec tabdict /glyf 3 -1 roll put
+    } {
+      pop
+    } ifelse
+    /sfnts [
+      offsets tabs { concatstrings } forall
+      tabs {
+        0 4 getinterval tabdict exch get
+        dup type /stringtype ne { aload pop } if
+      } forall
+    ] def
+  } bind def
+  
+  % <glyfs> .cjkv_dividesfnts <glyfs'>
+  /.cjkv_dividesfnts {
+    CJKV_DEBUG_TT42 { (.cjkv_dividesfnts\n) print flush } if
+    /glyfs exch def
+    /len1 0 glyfs { length add } forall def
+  		% Determine where to split the glyfs by scanning loca.
+  		% The very last entry in loca may be bogus.
+  		% Note that some loca entries may be odd, but we can only
+  		% split at even positions.
+  		%
+  		% Construct splitarray, the array of final lengths of
+  		% the sfnts entries covering the glyfs (i.e., all but
+  		% the first and last sfnts entries).
+      /prevsplit 0 def
+      /prevboundary 0 def
+      /prevoddboundary 0 def % see TYPE42_NO_ODDSIZE_STR in zfont42.c
+      /splitarray [
+        0 1 numloca 1 sub {
+  	_cjkv_type42_tmp /getloca get exec dup prevsplit maxstring add gt {
+            prevboundary prevsplit eq { % see TYPE42_NO_ODDSIZE_STR in zfont42.c
+               /ferr (%stderr) (w) file def
+               ferr (glyf table ) writestring
+               ferr prevsplit 10 string cvs writestring
+               ferr ( - ) writestring
+               dup 10 string cvs ferr exch writestring
+               ferr ( too long segment without suitable boundary.\n)
+               writestring
+               ferr closefile
+               /prevboundary prevoddboundary def
+            } if
+            CJKV_DEBUG_TT42 {
+               dup 10 string cvs print
+               ( segment is longer than maxstring, split now ) print
+               prevboundary 10 string cvs print
+               ( - ) print
+               prevsplit 10 string cvs print
+               (\n) print
+            } if
+  	  prevboundary prevsplit sub exch
+  	  /prevsplit prevboundary def
+            % /prevoddboundary 0 def
+  	} if
+  	dup 1 and 0 eq { % see TYPE42_NO_ODDSIZE_STR in zfont42.c
+            CJKV_DEBUG_TT42 {
+              dup 10 string cvs print
+              ( \() print
+              dup prevsplit sub 10 string cvs print
+              (\) ) print
+              ( even length OK\n) print
+  	} if
+            /prevboundary exch def
+            % /prevoddboundary 0 def
+          } {
+            CJKV_DEBUG_TT42 {
+              dup 10 string cvs print
+              ( \() print
+              dup prevsplit sub 10 string cvs print
+              (\) ) print
+              ( odd length!\n) print
+  	} if
+            % prevoddboundary 0 eq {
+              /prevoddboundary exch def
+            % } { pop } ifelse
+          } ifelse
+          % dup 0 eq { (why ZERO?\n) print } if
+          % dup ==
+        } for
+        len1 prevsplit sub
+      ] def
+      currentuserparams /VMReclaim get -2 vmreclaim
+      [
+  		% Re-split the sfnts glyfs strings according to splitarray.
+  		% We do this by iterating over the final segments defined
+  		% by splitarray, and constructing them from pieces of the
+  		% current glyfs strings.  We recycle the current strings
+  		% when possible, to avoid stressing the allocator.
+        /sfnt_idx 0 def
+        /strpos 0 def
+        _cjkv_type42_tmp /avail () put
+        splitarray {
+  	/seglen exch def
+  	/segpos 0 def
+  	_cjkv_type42_tmp /avail get length seglen ge
+  	  { _cjkv_type42_tmp /avail get 0 seglen getinterval _cjkv_type42_tmp /avail () put } { seglen string }
+  	ifelse
+  	{
+  	  /str glyfs sfnt_idx get def
+  	  /strlen str length def
+  	  /strleft strlen strpos sub def
+  	  seglen segpos sub strleft lt { exit } if
+  		% Copy the (rest of the) string into the new segment.
+  		% We know strleft <= segleft.
+  	  dup segpos str strpos strleft getinterval putinterval
+  	  /segpos segpos strleft add def
+  	  _cjkv_type42_tmp /avail str put
+  	  /sfnt_idx sfnt_idx 1 add def
+  	  /strpos 0 def
+  	  segpos seglen eq { exit } if
+  	} loop
+  		% Fill up the segment with an initial piece of the next
+  		% existing glyfs string.  We know strleft > segleft.
+  	/segleft seglen segpos sub def
+  	dup segpos str strpos segleft getinterval putinterval
+  	/strpos strpos segleft add def
+        } forall
+      ]
+      exch vmreclaim
+  } bind def
+  
+  
+  % - .cjkv_getpost -
+  % Uses post, defines glyphencoding
+  /.getpost {
+    CJKV_DEBUG_TT42 { (.getpost\n) print flush } if
+    /glyphencoding post null eq {
+      CJKV_DEBUG_TT42 { (post missing) = flush } if [ ]
+    } {
+      postformats post 0 .cjkv_getu32 .knownget {
+        CJKV_DEBUG_TT42 {
+          (post: format ) print
+          post 0 .cjkv_getu16 =only (,) print post 2 .cjkv_getu16 = flush
+        } if
+        post exch exec
+      } {
+        CJKV_DEBUG_TT42 { (post: unknown format ) print post 0 .cjkv_getu32 = flush } if [ ]
+      } ifelse
+    } ifelse def
+  } bind def
+  
+  % - .cjkv_ttkeys <key> <value> ...
+  /.cjkv_ttkeys {
+    CJKV_DEBUG_TT42 { (.cjkv_ttkeys\n) print flush } if
+    count /ttkeycount exch def
+    /upem head 18 .cjkv_getu16 def
+    /FontMatrix matrix
+    /FontBBox [ 36 2 42 { head exch .cjkv_gets16 upem div } for ]
+    .cjkv_nextxuid
+    tabdict /name .knownget {
+  		% Find the names from the 'name' table.
+      /names exch def
+      /FontName names 6 .cjkv_findname not { .cjkv_curxuid 16 8 string cvrs } if
+        /fontname 1 index def
+      /FontInfo mark
+        names 0 .cjkv_findname { /Notice exch } if
+        names 1 .cjkv_findname { /FamilyName exch } if
+        names 4 .cjkv_findname { /FullName exch } if
+        names 5 .cjkv_findname { /Version exch } if
+    } {
+  		% No name table, fabricate a FontName.
+      /FontName .cjkv_curxuid 16 8 string cvrs
+        /fontname 1 index def
+      /FontInfo mark
+    } ifelse
+    CJKV_DEBUG_TT42 { (fontname ) print fontname = } if
+  		% Stack: ... /FontInfo mark key1 value1 ...
+    post null ne {
+      post type /arraytype eq {
+        % this post table is a big table. /post should be [(...) ...]
+        % data we actually need here should be first one in array.
+        /posttable post 1 get def
+      } {
+        /posttable post def
+      } ifelse
+      /ItalicAngle        posttable  4 .cjkv_gets32 65536.0 div
+      /isFixedPitch       posttable 12 .cjkv_getu32 0 ne
+      /UnderlinePosition  posttable  8 .cjkv_gets16 upem div
+      /UnderlineThickness posttable 10 .cjkv_gets16 upem div
+    } if
+    counttomark 0 ne { .dicttomark } { pop pop } ifelse
+    /XUID [orgXUID 42 .cjkv_curxuid]
+    CJKV_DEBUG_TT42 {
+      tabs { _cjkv_type42_util /.cjkv_printtab get exec } forall
+      [ sfnts { length } forall ] ==
+      count ttkeycount sub array astore dup { == } forall aload pop
+    } if
+    /sfnts sfnts
+  } bind def
+  
+  % ---------------- Standard TrueType font loading ---------------- %
+  
+  % - .cjkv_pickcmap -
+  % Defines cmapsub, cmaptab
+  /.cjkv_pickcmap {
+    CJKV_DEBUG_TT42 { (.cjkv_pickcmap\n) print flush } if
+    tabdict /cmap get
+  		% The Apple cmap format is no help in determining the encoding.
+  		% Look for a Microsoft table.  If we can't find one,
+  		% just use the first table, whatever it is.
+    dup 4 8 .cjkv_biggetinterval exch             % the default
+    0 1 2 index 2 .cjkv_biggetu16 1 sub {
+      8 mul 4 add 1 index exch 8 .cjkv_biggetinterval
+      dup 0 .cjkv_biggetu16 /cmap_platform exch def
+      dup 2 .cjkv_biggetu16 /cmap_encoding exch def
+      CJKV_DEBUG_TT42 {
+        (cmap: platform ) print cmap_platform =only
+        ( encoding ) print cmap_encoding = flush
+      } if
+      cmap_platform 3 eq { exch 3 -1 roll pop exit } if pop
+    } for
+  		% Stack: subentry table
+    /cmapsub 2 index _cjkv_ttcmap_tmp 3 1 roll put
+    exch 4 .cjkv_biggetu32 1 index .cjkv_biglength 1 index sub .cjkv_biggetinterval
+    /cmaptab exch _cjkv_ttcmap_tmp 3 1 roll put
+  } bind def
+  
+  % <glyph> .cjkv_nname <_name>
+  /.cjkv_nname {
+    CJKV_DEBUG_TT42 { (.cjkv_nname\n) print flush } if
+    =string cvs (_) exch concatstrings cvn
+  } bind def
+  
+  % - .cjkv_charkeys /CharStrings <charstrings> /Encoding <encoding>
+  % Resets glyphencoding
+  /.cjkv_charkeys {
+    CJKV_DEBUG_TT42 { (.cjkv_charkeys\n) print flush } if
+    CJKV_DEBUG_TT42 {
+      (glyphencoding: length=) print glyphencoding dup length = === flush
+    } if
+  		% Hack: if there is no usable post table but the cmap uses
+  		% the Microsoft Unicode encoding, use ISOLatin1Encoding.
+    glyphencoding length 0 eq _cjkv_ttcmap_tmp /cmapsub get 0 4 getinterval <00030001> eq and {
+      /glyphencoding ISOLatin1Encoding dup length array copy def
+    } if
+  		% If necessary, fabricate additional glyphencoding entries
+  		% to cover all of loca, or truncate glyphencoding.
+    glyphencoding length numloca lt {
+      /glyphencoding [ glyphencoding aload pop
+      counttomark 1 numloca 1 sub { .cjkv_nname } for ] def
+    } {
+      /glyphencoding glyphencoding 0 numloca getinterval def
+    } ifelse
+  		% Some badly designed Chinese fonts have a post table
+  		% in which all glyphs other than 0 are named .null.
+  		% Use CharStrings to keep track of the reverse map from
+  		% names to glyphs, and don't let any name be used for
+  		% more than one glyph.
+    /CharStrings glyphencoding dup length 1 add dict	% +1 for .notdef
+      0 1 3 index length 1 sub {
+  		% Stack: glyphencoding dict index
+        2 index 1 index get 2 index 1 index known {
+  		% The same name maps to more than one glyph.
+  		% Change the name.
+  	pop dup .cjkv_nname 3 index 2 index 2 index put
+        } if
+        2 index exch 3 -1 roll put
+      } for exch pop
+  		% If there is no .notdef entry, map it to glyph 0.
+    dup /.notdef known not { dup /.notdef 0 put } if
+    readonly
+    /Encoding
+      [ _cjkv_ttcmap_tmp /cmaptab get _cjkv_cmaparray dup length 256 gt { 0 256 getinterval } if
+      { glyphencoding exch get } forall
+      counttomark 256 exch sub { /.notdef } repeat ]
+    CJKV_DEBUG_TT42 { (Encoding: ) print dup === flush } if
+  } bind def
+  
+  % -mark- <key> <value> ... .cjkv_definettfont <font>
+  /.cjkv_definettfont {
+    CJKV_DEBUG_TT42 { (.cjkv_definettfont\n) print flush } if
+    /FontType 42
+    /PaintType 0
+    CJKV_DEBUG_TT42 {
+      (numloca=) print numloca =
+    } if
+    .dicttomark
+    end end dup /FontName get exch definefont
+  } bind def
+  
+  
+  % <file> .cjkv_loadttfont <type42font>
+  /.cjkv_loadttfont {
+    CJKV_DEBUG_TT42 { (.cjkv_loadttfont\n) print flush } if
+    .cjkv_loadttfonttables
+    .cjkv_makesfnts
+    .cjkv_getpost
+    .cjkv_pickcmap
+    mark
+    .cjkv_charkeys
+    .cjkv_ttkeys
+    .cjkv_definettfont
+  } bind def
+
+end readonly def
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/cjkvttcf.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,154 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Taiji Yamada, Hideyuki Suzuki, Masatake Yamato and suzuki toshiya.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+
+[
+   /CJKV_DEBUG_TTCF
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+% /Charset /TTEncoding .cjkv_buildcmaptab cmap
+/.cjkv_buildcmaptab {
+  _cjkv_type11_util /.cjkv_buildcmapdict get 3 2 roll get begin
+  cvx exec exch CIDCounts end exch get array
+  dup length 1 sub 0 1 3 -1 roll { 1 index exch cmapglyphs 0 get put } for
+  exch exec
+} bind def
+
+% -mark- <key> <value> ... .cjkv_definettcidfont <font>
+%   rapid version of .definecjkvttcidfont
+% Proposed by Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+% Modified by Taiji Yamada <taiji@aihara.co.jp>
+/.cjkv_definettcidfont {
+  CJKV_DEBUG_TTCF { (--- start cjkv_definettcidfontk\n) print flush } if
+  true setglobal
+  CJKV_DEBUG_TTCF { (--- making scratch dict...\n) print flush } if
+  15 _cjkv_base_util /.cjkv_newdicttomark get exec
+  CJKV_DEBUG_TTCF { (---                       ok\n) print flush } if
+  dup /CIDFontName fontname dup length string copy put
+  CJKV_DEBUG_TTCF { (--- CIDFontName put ok\n) print flush } if
+  dup /CIDFontType 2 put
+  CJKV_DEBUG_TTCF { (--- CIDFontType put ok\n) print flush } if
+  dup /CIDSystemInfo
+    mark
+    _cjkv_type11_tmp /.cjkv_ttencmapproc get exec
+    {
+      _cjkv_type11_util /.cjkv_buildcmapdict get 3 2 roll get begin
+      cvx exec pop
+      /Supplement exch
+      /Registry Registry
+      /Ordering Ordering
+      end
+    } {
+      /Registry (Adobe)
+      /Ordering (Identity)	% pursuant to makeIdentityCMap in pdf_font.ps
+      /Supplement 0
+    } ifelse
+    0 _cjkv_base_util /.cjkv_newdicttomark get exec put
+  CJKV_DEBUG_TTCF { (--- CIDSystemInfo define ok\n) print flush } if
+  dup /CharStrings mark /.notdef 0 .dicttomark put
+  CJKV_DEBUG_TTCF { (--- CharStrings define ok\n) print flush } if
+  _cjkv_type11_tmp /.cjkv_ttencmapproc get exec {
+    /cmapglyphs _cjkv_ttcmap_tmp /cmaptab get _cjkv_cmaparray def
+    exec .cjkv_buildcmaptab
+    dup length /CIDCount exch
+    3 -1 roll _cjkv_type11_util /.cjkv_makecidmap get exec	% it has not supported a dictionary yet
+    /CIDMap exch		% it should be a string or an array of strings
+    4 index 3 1 roll put
+    2 index 3 1 roll put
+  } {
+    dup /CIDCount numloca put
+    dup /CIDMap 0 put	% an integer interpreted as an offset from GI (see #5012 p.16)
+  } ifelse
+  dup /GDBytes 2 put
+  CJKV_DEBUG_TTCF { (--- GDBytes define ok\n) print flush pstack } if
+  dup /Encoding [ 256 { /.notdef } repeat ] put
+  CJKV_DEBUG_TTCF { (--- Encoding define ok\n) print flush } if
+  end end dup /CIDFontName get exch /CIDFont defineresource
+  CJKV_DEBUG_TTCF { (--- defineresource ok\n) print flush pstack } if
+} bind def
+
+% Load a TrueType font from a file as a CIDFontType 2 font.
+%   rapid version of .loadcjkvttcidfont
+% Proposed by Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+% Modified by Taiji Yamada <taiji@aihara.co.jp>
+%
+% <file>             .cjkv_loadttcidfont <cidtype2font>
+% <file> <fontindex> .cjkv_loadttcidfont <cidtype2font>
+%   detect a kind of CID and encode a TrueType font to a CID-Keyed font.
+%
+% <file>             <ttcidcode> .cjkv_loadttcidfont <cidtype2font>
+% <file> <fontindex> <ttcidcode> .cjkv_loadttcidfont <cidtype2font>
+%   load a TrueType font and encode it with the kind of CID described
+%   in <ttcidcode> which is one of entry in .cjkv_ttencmap.
+/.loadcjkvttcidfont {
+  CJKV_DEBUG_TTCF { (*** START: .loadcjkvttcidfont: dictstack=) print countdictstack == flush } if
+  dup type /nametype ne { /Auto } if
+  1 index type /integertype eq { 3 1 roll } { exch } ifelse
+  CJKV_DEBUG_TTCF { (*** setup finished dictstack=) print countdictstack == flush } if
+  _cjkv_type42_util /.cjkv_loadttfonttables get exec
+  CJKV_DEBUG_TTCF { (*** loadttfonttables finished dictstack=) print countdictstack == flush } if
+  _cjkv_type42_util /.cjkv_makesfnts get exec
+  CJKV_DEBUG_TTCF { (*** makesfnts finished dictstack=) print countdictstack == flush } if
+  _cjkv_type42_util /.cjkv_pickcmap get exec
+  CJKV_DEBUG_TTCF { (*** pickcmap finished dictstack=) print countdictstack == flush } if
+  _cjkv_type11_util /.cjkv_getgsub get exec
+  CJKV_DEBUG_TTCF { (*** getgsub finished dictstack=) print countdictstack == flush } if
+  _cjkv_type11_util /.cjkv_getos2 get exec
+  CJKV_DEBUG_TTCF { (*** getos2 finished dictstack=) print countdictstack == flush } if
+  _cjkv_type11_util /.cjkv_ttencmap get
+  exch get _cjkv_type11_tmp exch /.cjkv_ttencmapproc exch put
+  CJKV_DEBUG_TTCF { (*** ttencmap finished dictstack=) print countdictstack == flush } if
+  mark
+  _cjkv_type42_util /.cjkv_ttkeys get exec
+  CJKV_DEBUG_TTCF { (*** ttkeys finished dictstack=) print countdictstack == flush } if
+  .cjkv_definettcidfont
+  CJKV_DEBUG_TTCF { (*** END: definettcidfont finished dictstack=) print countdictstack == flush } if
+} bind def
+
+% Open and load a TrueType font from a file as a CIDFontType 2 font.
+% <filename>             .openttcidfont <cidtype2font>
+% <filename> <fontindex> .openttcidfont <cidtype2font>
+% <filename>             <ttcidcode> .openttcidfont <cidtype2font>
+% <filename> <fontindex> <ttcidcode> .openttcidfont <cidtype2font>
+/.openttcidfont {
+  1 dup index type /nametype eq { 1 add } if
+  dup index type /integertype eq { 1 add } if
+  dup 1 add -1 roll (r) file exch 1 roll
+  .loadcjkvttcidfont	% rapid version, since 20010316
+  CJKV_DEBUG_TTCF { (*** .openttcidfont ok\n) print flush } if
+} bind def
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/baseutil.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,569 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Taiji Yamada, Masatake Yamato, Hideyuki Suzuki and suzuki toshiya.
+%   Enhancements by Akira Tagoh and Taiji Yamada, 2005.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+[
+   /CJKV_DEBUG_BASE
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+/_cjkv_ttcmap_tmp 10 dict def
+
+/_cjkv_base_util 50 dict dup begin
+
+  /.cjkv_newdicttomark { % <mark> <k1> <v1> ... <kn> <vn> <extra_space> .cjkv_newdicttomark <dict>
+    CJKV_DEBUG_BASE { (--- .cjkv_newdicttomark start\n) print flush  } if
+    counttomark 1 sub 2 idiv add dict   % <mark> <k1> <v1> ... <kn> <vn> <dict>
+    CJKV_DEBUG_BASE { (--- scratch dict making finished\n) print flush  } if
+    counttomark 1 sub 2 idiv {
+      dup                               % <mark> <k1> <v1> ... <kn> <vn> <dict> <dict>
+      4 2 roll                          % <mark> <k1> <v1> ... <dict> <dict> <kn> <vn>
+      dup type /stringtype eq { dup length string copy } if
+      dup type /arraytype  eq {
+        dup length array exch dup length 0 exch 1 exch 1 sub {
+          1 index 1 index get dup type /stringtype eq {
+            dup length string copy
+          } if
+          [ exch ]
+          3 index 3 1 roll putinterval
+        } for
+        pop
+      } if
+      dup type /dicttype   eq {
+        dup length dict exch
+        [ 1 index { pop } forall ] {
+          1 index 1 index get dup type /stringtype eq {
+            dup length string copy
+          } if
+          3 index 3 1 roll put
+        } forall
+        pop
+      } if
+      put                               % <mark> <k1> <v1> ... <dict>
+      CJKV_DEBUG_BASE { (--- copy ok\n) print flush  } if
+    } repeat                            % <mark> <dict>
+    exch pop                            % <dict>
+    CJKV_DEBUG_BASE { (--- .cjkv_newdicttomark ok\n) print flush  } if
+  } bind def
+
+  /orgXUID AladdinEnterprisesXUID def
+  /maxstring 32000 def    % half the maximum length of a PostScript string,
+                          % must be a multiple of 4 (for hmtx / loca / vmtx)
+  
+
+  /.cjkv_xuidstring <80000000> def
+
+  /.cjkv_curxuid {              % - curxuid <int>
+    0 .cjkv_xuidstring { exch 8 bitshift exch add } forall
+  } bind def
+
+  /.cjkv_nextxuid {             % - nextxuid -
+    3 -1 0 {
+      .cjkv_xuidstring 1 index 2 copy get dup 255 ne {
+        1 add put pop exit
+      } if pop 0 put pop
+    } for
+  } bind def
+  
+  % <string> <index> .cjkv_getu16 <integer>
+  /.cjkv_getu16 {
+    2 copy get 8 bitshift 3 1 roll 1 add get add
+  } bind def
+  
+  % <string> <index> .cjkv_gets16 <integer>
+  /.cjkv_gets16 {
+    .cjkv_getu16 16#8000 xor 16#8000 sub
+  } bind def
+  
+  % <string> <index> .cjkv_getu32 <integer>
+  /.cjkv_getu32 {
+    2 copy .cjkv_getu16 16 bitshift 3 1 roll 2 add .cjkv_getu16 add
+  } bind def
+  
+  % <string> <index> .cjkv_gets32 <integer>
+  /.cjkv_gets32 {
+    2 copy .cjkv_gets16 16 bitshift 3 1 roll 2 add .cjkv_getu16 add
+  } bind def
+  
+  % <string> <index> <integer> .cjkv_putu16 -
+  /.cjkv_putu16 {
+    3 copy -8 bitshift put
+    exch 1 add exch 16#ff and put
+  } bind def
+  
+  % <string> <index> <integer> .cjkv_putu32 -
+  /.cjkv_putu32 {
+    3 copy -16 bitshift .cjkv_putu16
+    exch 2 add exch 16#ffff and .cjkv_putu16
+  } bind def
+
+  /.cjkv_biglength { % <str>|<array of str> .biglength <integer>
+    dup type /arraytype eq { 0 exch { length add } forall } { length } ifelse
+  } bind def
+  
+  /.cjkv_concats { % [str ...] concats str
+    () exch dup length 1 sub -1 0 {
+      1 index exch get dup type /stringtype ne { dup length string cvs } if
+      3 -1 roll exch dup length 2 index length add string
+      dup dup 4 2 roll copy length 4 -1 roll putinterval exch
+    } for pop
+  } bind def
+  
+  % <str>|<array of str> <index> <count> .cjkv_biggetinterval <str>|<array of str>
+  /.cjkv_biggetinterval {
+    currentglobal 4 1 roll
+    false setglobal
+    5 dict begin
+    2 index type /arraytype eq {
+      /c exch def
+      /i exch def
+      [ exch {
+        dup length /l exch def
+        i c add l gt {
+          i l lt {
+            i l i sub getinterval
+            /c i c add l sub def
+            /i 0 def
+          } {
+            pop
+            /i i l sub def
+          } ifelse
+        } {
+          i c getinterval exit
+        } ifelse
+      } forall
+      counttomark array dup length 1 sub -1 0 { 1 index exch 3 index put exch pop } for exch pop
+      dup .cjkv_biglength 65535 le { .cjkv_concats } if
+    } { getinterval } ifelse
+    end
+    exch setglobal
+  } bind def
+  
+  % <str>|<array of str> <index> .cjkv_biggetu16 <integer>
+  /.cjkv_biggetu16 {
+    2 .cjkv_biggetinterval 0 .cjkv_getu16
+  } bind def
+  
+  % <str>|<array of str> <index> .cjkv_biggetu32 <integer>
+  /.cjkv_biggetu32 {
+    4 .cjkv_biggetinterval 0 .cjkv_getu32
+  } bind def
+  
+  % <string> .cjkv_strtoint <integer>
+  /.cjkv_strtoint {
+    0 exch { exch 8 bitshift add } forall
+  } bind def
+  
+  % <nametable> <nameid> findname <string> true
+  % <nametable> <nameid> findname false
+  /.cjkv_findname {
+    CJKV_DEBUG_BASE { (findname: ) print dup =only  } if
+    false 3 1 roll 0 1 3 index 2 .cjkv_getu16 1 sub {
+                  % Stack: false table id index
+      12 mul 6 add 2 index exch 12 getinterval
+      dup 6 .cjkv_getu16 2 index eq {
+                  % We found the name we want.
+        exch pop
+                  % Stack: false table record
+        dup 10 .cjkv_getu16 2 index 4 .cjkv_getu16 add
+        1 index 8 .cjkv_getu16 4 -1 roll 3 1 roll getinterval exch
+                  % Stack: false string record
+                  % Check for 8- vs. 16-bit characters.
+        .cjkv_is2byte { .cjkv_string2to1 } if true null 4 -1 roll exit
+      } if pop
+    } for pop pop
+    CJKV_DEBUG_BASE {
+      dup { ( = ) print 1 index == } { ( not found) = } ifelse
+    } if
+  } bind def
+  
+  % <namerecord> .cjkv_is2byte <bool>
+  /.cjkv_is2byte {
+    dup 0 .cjkv_getu16 {
+      { pop true }                % Apple Unicode
+      { pop false }               % Macintosh Script manager
+      { 1 .cjkv_getu16 1 eq }           % ISO
+      { 1 .cjkv_getu16 1 eq }           % Microsoft
+    } exch get exec
+  } bind def
+  
+  % <string2> string2to1 <string>
+  /.cjkv_string2to1 {
+    dup length 2 idiv string dup
+    0 1 3 index length 1 sub {
+      3 index 1 index 2 mul 1 add get put dup
+    } for pop exch pop
+  } bind def
+  
+
+  % <array> <lt-proc> .cjkv_sort <array>
+  /.cjkv_sort {
+    1 index length 1 sub -1 1 {
+      2 index exch 2 copy get 3 copy      % arr proc arr i arr[i] arr i arr[i]
+      0 1 3 index 1 sub {
+        3 index 1 index get       % arr proc arr i arr[i] arr imax amax j arr[j]
+        2 index 1 index 10 index exec {   % ... amax < arr[j]
+          4 2 roll
+        } if pop pop
+      } for                       % arr proc arr i arr[i] arr imax amax
+      4 -1 roll exch 4 1 roll put put
+    } for pop
+  } def
+  
+  
+  % <array|string> <index> <count> .cjkv_safegetinterval <subarray|substring>
+  /.cjkv_safegetinterval {
+    exch 2 index length .min exch
+    2 index length 2 index sub .min
+    getinterval
+  } bind def
+  
+  % <array> <index> <obj> .cjkv_safeput -
+  /.cjkv_safeput {
+    2 index length 2 index gt { put } { pop pop pop } ifelse
+  } bind def
+  
+  % Each procedure in this dictionary is called as follows:
+  %       <encodingtable> proc <glypharray>
+  /_cjkv_cmapformats mark
+    0 {		% Apple standard 1-to-1 mapping.
+      6 256 getinterval { } forall 256 packedarray
+    } bind
+    2 {		% Apple 16bit CJK (ShiftJIS etc)
+  
+      % /sHK_sz		subHeaderKey_size	% 1 * uint16
+      % /sH_sz		subHeader_size		% 4 * uint16
+      % /sH_len		subHeader_length
+      % /cmapf2_tblen	total table length
+      % /cmapf2_lang	language code (not used)
+      % /sHKs		subHeaderKeys
+  
+      /sHK_sz 2 def
+      /sH_sz 8 def
+      dup 2 .cjkv_getu16 /cmapf2_tblen exch def
+  
+      CJKV_DEBUG_BASE {
+         (format2 table length: 0x) print
+         cmapf2_tblen 16 10 string cvrs print
+         (=) print
+         cmapf2_tblen == flush
+      } if
+      dup 4 .cjkv_getu16 /cmapf2_lang exch def
+  
+      CJKV_DEBUG_BASE {
+         (format2 lang code: 0x) print
+         cmapf2_lang 16 10 string cvrs == flush
+      } if
+      dup 6 256 sHK_sz mul getinterval /sHKs exch def
+      CJKV_DEBUG_BASE {
+         (format2 subHeaderKeys: ) print
+         sHKs == flush
+         (scan subHeaderKeys\n) print flush
+      } if
+  
+      0		% initialization value for /sH_len
+      0 1 255 {
+         CJKV_DEBUG_BASE {
+            (hi byte ) =only
+            dup 16 10 string cvrs =only
+            (-> subHeader #) print
+            flush
+         } if
+         sHKs exch
+         2 mul .cjkv_getu16
+         CJKV_DEBUG_BASE {
+            dup 16 10 string cvrs =only
+            ( ) print dup == flush
+         } if
+         1 index	% get current max
+         1 index	% get current subHeaderKey
+         lt {exch} if pop
+      } for
+      /sH_len exch def
+  
+      CJKV_DEBUG_BASE {
+        (format2 subHeader length: ) print
+        sH_len ==
+        flush
+      } if
+      dup 6 256 sHK_sz mul add
+      cmapf2_tblen 1 index sub getinterval
+      /sH_gIA exch def
+      CJKV_DEBUG_BASE {
+         (format2 subHeaders + GID array: ) print
+         sH_gIA ==
+      } if
+  
+      /cmapf2_glyph_array 65535 array def
+  
+      /.cmapf2_putGID {
+          /cmapf2_ch cmapf2_ch_hi 8 bitshift cmapf2_ch_lo add def
+          CJKV_DEBUG_BASE {
+              (code: ) =only cmapf2_ch 16 4 string cvrs =only
+              ( -> ) =only
+          } if
+          firstCode cmapf2_ch_lo le
+          cmapf2_ch_lo firstCode entryCount add lt
+          and { % true: j is inside
+              sH_offset idRangeOffset add		% offset to gI
+              cmapf2_ch_lo firstCode sub 2 mul	% rel. pos. in range
+              add 6 add				% offset in sH_gIA
+              sH_gIA exch .cjkv_getu16
+              dup 0 gt { % 
+                  CJKV_DEBUG_BASE {
+                      dup 16 8 string cvrs =only
+                      (+) =only idDelta 16 8 string cvrs =only
+                  } if
+                  idDelta add
+                  CJKV_DEBUG_BASE {
+                      (=) =only dup 16 8 string cvrs == flush
+                  } if
+                  cmapf2_glyph_array exch cmapf2_ch exch put
+              } {
+                  CJKV_DEBUG_BASE {(specified 0: 0\n) print flush} if
+                  pop
+                  % cmapf2_glyph_array cmapf2_ch 0 put
+              } ifelse
+          } {   % false: j is outside
+              CJKV_DEBUG_BASE {(outside of range: 0\n) print flush} if
+              % cmapf2_glyph_array cmapf2_ch 0 put
+          } ifelse
+      } def
+  
+      16#00 1 16#ff { % hi_byte scan
+          /cmapf2_ch_hi exch def
+          sHKs cmapf2_ch_hi sHK_sz mul .cjkv_getu16
+          CJKV_DEBUG_BASE {
+              (subHeader_offset = idx * 8 = ) print
+              dup ==
+          } if
+          /sH_offset exch def
+          sH_gIA sH_offset sH_sz getinterval
+              dup 0 .cjkv_getu16 /firstCode exch def
+              dup 2 .cjkv_getu16 /entryCount exch def
+              dup 4 .cjkv_gets16 /idDelta exch def
+              dup 6 .cjkv_getu16 /idRangeOffset exch def
+          pop
+          CJKV_DEBUG_BASE {
+             (idRangeOffset: ) print idRangeOffset 16 8 string cvrs ==
+          } if
+          sH_offset 0 eq {
+             /cmapf2_ch_lo cmapf2_ch_hi def
+             /cmapf2_ch_hi 0 def
+             .cmapf2_putGID
+          } {
+             16#00 1 16#ff { % lo_byte scan
+                 /cmapf2_ch_lo exch def
+                 .cmapf2_putGID
+             } for
+          } ifelse
+       } for
+       pop
+       0 1 cmapf2_glyph_array length 1 sub { % rewrite null -> 0.
+          % CJKV_DEBUG_BASE { (rewriting null: ) print dup == flush } if
+          dup cmapf2_glyph_array exch get
+          null eq { cmapf2_glyph_array exch 0 put } {pop} ifelse 
+       } for
+       CJKV_DEBUG_BASE { (rewriting finished\n) print flush } if
+       cmapf2_glyph_array
+       CJKV_DEBUG_BASE {
+         16#0000 16#0010 16#fff0 {
+            16#0000 16#0001 16#000f {
+               1 index add dup 16#ffff lt {
+                 2 index exch get =only
+                 ( ) =only
+               } { pop } ifelse
+            } for
+            pop
+            (\n) print flush
+         } for
+       } if
+    } bind
+    4 {		% Microsoft/Adobe segmented mapping.
+      /etab exch _cjkv_ttcmap_tmp 3 1 roll put
+      /nseg2 _cjkv_ttcmap_tmp /etab get 6 .cjkv_biggetu16 def
+      14 /endc _cjkv_ttcmap_tmp /etab get 2 index nseg2 .cjkv_biggetinterval _cjkv_ttcmap_tmp 3 1 roll put
+  		% The Apple TrueType documentation omits the 2-byte
+  		% 'reserved pad' that follows the endCount vector!
+      2 add
+      nseg2 add /startc _cjkv_ttcmap_tmp /etab get 2 index nseg2 .cjkv_biggetinterval _cjkv_ttcmap_tmp 3 1 roll put
+      nseg2 add /iddelta _cjkv_ttcmap_tmp /etab get 2 index nseg2 .cjkv_biggetinterval _cjkv_ttcmap_tmp 3 1 roll put
+      nseg2 add /idroff _cjkv_ttcmap_tmp /etab get 2 index nseg2 .cjkv_biggetinterval  _cjkv_ttcmap_tmp 3 1 roll put
+  		% The following hack allows us to properly handle
+  		% idiosyncratic fonts that start at 0xf000:
+      pop
+      /firstcode _cjkv_ttcmap_tmp /startc get 0 .cjkv_getu16 16#ff00 and dup 16#f000 ne { pop 0 } if def
+      _cjkv_ttcmap_tmp /putglyph {
+        glyphs code 3 -1 roll put /code code 1 add def
+      } bind put
+  		% Do a first pass to compute the size of the glyphs array.
+      /numcodes 0 def /glyphs 0 0 2 nseg2 3 sub {
+  		% Stack: /glyphs numglyphs i2
+        /i2 exch def
+        /scode _cjkv_ttcmap_tmp /startc get i2 .cjkv_biggetu16 def
+        /ecode _cjkv_ttcmap_tmp /endc get i2 .cjkv_biggetu16 def
+        numcodes scode firstcode sub
+  		% Hack for fonts that have only 0x0000 and 0xf000 ranges
+        %dup 16#e000 ge { 255 and } if
+        % the previous line is obstructive to CJK fonts, so it was removed
+        exch sub 0 .max ecode scode sub 1 add add
+        exch 1 index add exch
+        numcodes add /numcodes exch def
+      } for array def
+  		% Now fill in the array.
+      /numcodes 0 def /code 0 def
+      0 2 nseg2 3 sub {
+        /i2 exch def
+        /scode _cjkv_ttcmap_tmp /startc get i2 .cjkv_getu16 def
+        /ecode _cjkv_ttcmap_tmp /endc get i2 .cjkv_getu16 def
+        numcodes scode firstcode sub
+  		% Hack for fonts that have only 0x0000 and 0xf000 ranges
+        %dup 16#e000 ge { 255 and } if
+        % the previous line is obstructive to CJK fonts, so it was removed
+        exch sub 0 .max dup { 0 _cjkv_ttcmap_tmp /putglyph get exec } repeat
+        ecode scode sub 1 add add numcodes add /numcodes exch def
+        /delta _cjkv_ttcmap_tmp /iddelta get i2 .cjkv_gets16 def
+        CJKV_DEBUG_BASE {
+  	(scode=) print scode =only
+  	( ecode=) print ecode =only
+  	( delta=) print delta =only
+  	( droff=) print _cjkv_ttcmap_tmp /idroff get i2 .cjkv_biggetu16 =
+        } if
+        _cjkv_ttcmap_tmp /idroff get i2 .cjkv_biggetu16 dup 0 eq {
+  	pop scode delta add 65535 and 1 ecode delta add 65535 and
+  	{ _cjkv_ttcmap_tmp /putglyph get exec } for
+        } {	% The +2 is for the 'reserved pad'.
+          /gloff exch 14 nseg2 3 mul add 2 add i2 add add def
+          0 1 ecode scode sub {
+  	  2 mul gloff add _cjkv_ttcmap_tmp /etab get exch .cjkv_biggetu16
+  	  dup 0 ne { delta add 65535 and } if _cjkv_ttcmap_tmp /putglyph get exec
+  	} for
+        } ifelse
+      } for glyphs /glyphs null def	% for GC
+    } bind
+    6 {		% Single interval lookup.
+      dup 6 .cjkv_getu16 /firstcode exch def dup 8 .cjkv_getu16 /ng exch def
+      firstcode ng add array
+  		% Stack: tab array
+  		% Fill elements 0 .. firstcode-1 with 0
+      0 1 firstcode 1 sub { 2 copy 0 put pop } for
+      dup firstcode ng getinterval
+  		% Stack: tab array subarray
+  		% Fill elements firstcode .. firstcode+nvalue-1 with glyph values
+      0 1 ng 1 sub {
+        dup 2 mul 10 add 4 index exch .cjkv_getu16 3 copy put pop pop
+      } for pop exch pop
+    } bind
+  .dicttomark readonly def                % _cjkv_cmapformats
+  
+  % <cmaptab> _cjkv_cmaparray <glypharray>
+  /_cjkv_cmaparray {
+    dup 0 .cjkv_biggetu16
+  
+    _cjkv_cmapformats exch .knownget {
+      CJKV_DEBUG_BASE {
+        (cmap: format ) print 1 index 0 .cjkv_biggetu16 = flush
+      } if exec
+    } {
+      (Can't handle format ) print 0 .cjkv_biggetu16 = flush
+      0 1 255 { } for 256 packedarray
+    } ifelse
+    CJKV_DEBUG_BASE {
+      (cmap: length=) print dup length = dup ==
+    } if
+  } bind def
+  
+  % Each procedure in this dictionary is called as follows:
+  %	<file> <length> -proc- <string|array_of_strings>
+  % Note that each table must have an even length, because of a strange
+  % Adobe requirement that each sfnts entry have even length.
+  /_cjkv_readtables mark
+  	% Ordinary tables
+    (head) { .cjkv_readtable }
+    (hhea) { .cjkv_readtable }
+    (maxp) { .cjkv_readtable }
+    (name) { .cjkv_readtable }
+    (OS/2) { .cjkv_readtable }
+    (vhea) { .cjkv_readtable }
+  	% Big tables
+    (cmap) { .cjkv_readbigtable }
+    (glyf) { .cjkv_readbigtable }
+    (loca) { .cjkv_readbigtable }
+    (hmtx) { .cjkv_readbigtable }
+    (vmtx) { .cjkv_readbigtable }
+    (post) { .cjkv_readbigtable }
+  	% Tables only needed for embedding in PDF files
+    (cvt ) { .cjkv_readtable }
+    (fpgm) { .cjkv_readtable }
+    (prep) { .cjkv_readtable }
+    (GSUB) { .cjkv_readtable }
+  .dicttomark
+  % Normally there would be a 'readonly' here, but the ttf2pf utility wants
+  % to include the 'kern' table as well, so we leave the readtables dictionary
+  % writable.
+  def                % readtables
+
+  % Read a table as a single string.
+  % <file> <length> .readtable <string>
+  /.cjkv_readtable {
+    dup dup 1 and add string
+                  % Stack: f len str
+    dup 0 4 -1 roll getinterval
+                  % Stack: f str str1
+          % Because of the absurd PostScript specification that gives an
+          % error for reading into an empty string, we have to check for
+          % this explicitly here.
+    3 -1 roll exch
+    dup () ne { readstring } if pop pop
+  } bind def
+  
+  % Read a big table (one that may exceed 64K).
+  % <file> <length> .readbigtable <string[s]>
+  /.cjkv_readbigtable {
+    dup 65400 lt {
+      .cjkv_readtable
+    } {
+      currentuserparams /VMReclaim get -2 vmreclaim
+      [ 4 2 roll {
+                  % Stack: mark ... f left
+        dup maxstring le { exit } if
+        1 index maxstring string readstring pop 3 1 roll maxstring sub
+      } loop .cjkv_readtable ]
+      exch vmreclaim
+    } ifelse
+  } bind def
+end readonly def % /_cjkv_base_util
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/cjkfnmap.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,389 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Masatake Yamato, suzuki toshiya, Hideyuki Suzuki and Taiji Yamada.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+
+true setglobal
+
+[
+   /CJKV_DEBUG_FNMAP
+   /NOCIDFONTMAP
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+
+50 dict begin
+
+/.cjkv_filenamedirseparator (/) def
+/_cjkv_defaultcidfontmap (CIDFnmap) def
+
+% -------------------------------------------------------------------------------
+% taken from gs7.05/lib/gs_cidfn.ps
+
+% Define the name of the CID font map file.
+userdict /_cjkv_CIDFontmap 10 dict put
+
+% <dict> <file> .readCIDFontmap <dict>
+% Code from gs_fonts.ps::.readFontmap
+  /.cjkv_readCIDFontmap {
+    CJKV_DEBUG_FNMAP { (.cjkv_readCIDFontmap\n) print flush } if
+    { dup token not { closefile exit } if
+      dup (\032) eq { pop closefile exit } if
+      1 index token not
+       { (CIDFontmap entry for ) print dup =only
+         ( has no associated file or alias name!  Giving up.) = flush
+         {.cjkv_readCIDFontmap} 0 get 1 .quit
+       } if
+      dup type dup /stringtype eq exch /nametype eq or not
+       { (CIDFontmap entry for ) print 1 index =only
+         ( has an invalid file or alias name!  Giving up.) = flush
+         {.cjkv_readCIDFontmap} 0 get 1 .quit
+       } if
+                % stack: dict file cidfontname filename|aliasname
+      1 index type /stringtype eq
+      1 index type /nametype eq and 1 index xcheck and
+      1 index /run eq 2 index /.runlibfile eq or and {
+                % This is an inclusion entry.
+        pop findlibfile { exch pop } { file } ifelse
+        2 index exch .cjkv_readCIDFontmap pop
+      } {
+        exch dup type /stringtype eq {cvn} if exch
+       { 2 index token not
+          { (CIDFontmap entry for ) print 1 index =only
+            ( ends prematurely!  Giving up.) = flush
+            {.cjkv_readCIDFontmap} 0 get 1 .quit
+          } if
+         dup /; eq { pop 3 index 3 1 roll .growput exit } if
+         1 index type /nametype eq {
+           (CIDFontmap entry for ) print 2 index =only
+           (defines an alias! Giving up.) = flush
+           {.cjkv_readCIDFontmap} 0 get 1 .quit
+         } if
+         exch [ exch 3 -1 roll
+         dup type /integertype eq {
+           4 index token not
+           { (CIDFontmap entry for ) print 3 index =only
+             ( ends prematurely!  Giving up.) = flush
+             {.cjkv_readCIDFontmap} 0 get 1 .quit
+           } if
+         } if
+         dup /; eq not 1 index type /nametype eq and {
+           counttomark 2 eq {4} {5} ifelse index token not
+           { (CIDFontmap entry for ) print
+             counttomark 2 eq {3} {4} ifelse index =only
+             ( ends prematurely!  Giving up.) = flush
+             {.cjkv_readCIDFontmap} 0 get 1 .quit
+           } if
+         } if
+         dup /; eq {
+             pop ]
+             3 index 3 1 roll .growput exit
+         } if
+         pop
+       } loop
+      } ifelse
+    } loop
+  } bind def
+
+% <file> .cjkv_loadCIDFontmap -
+  /.cjkv_loadCIDFontmap {
+    CJKV_DEBUG_FNMAP { (.cjkv_loadCIDFontmap\n) print flush } if
+    userdict /_cjkv_CIDFontmap get exch
+    .cjkv_readCIDFontmap pop
+  } bind def
+
+% Code from .loadinitialfonts
+  /.cjkv_loadinitialcidfonts {
+    CJKV_DEBUG_FNMAP { (.cjkv_loadinitialcidfonts\n) print flush } if
+    NOCIDFONTMAP not {
+      /CIDFONTMAP where {
+        pop [ CIDFONTMAP .pathlist ] {
+          dup VMDEBUG findlibfile {
+            exch pop .cjkv_loadCIDFontmap
+          } {
+            /undefinedfilename signalerror
+          } ifelse
+        } forall
+      } {
+        LIBPATH {
+          _cjkv_defaultcidfontmap 2 copy .cjkv_filenamedirseparator
+          exch concatstrings concatstrings
+          3 1 roll pop pop dup
+          CJKV_DEBUG_FNMAP { (lookup CIDFnmap: ) print flush dup =only } if
+          VMDEBUG (r) { file } .internalstopped {
+            CJKV_DEBUG_FNMAP { ( ... not found\n) print flush } if
+            pop pop
+          } {
+            CJKV_DEBUG_FNMAP { ( ... found\n) print flush } if
+            .cjkv_loadCIDFontmap
+          } ifelse
+        } forall
+      } ifelse
+    } if
+ } bind def
+
+ .cjkv_loadinitialcidfonts
+
+  /_cjkv_CIDFontmapHandler <<
+    /nametype {
+      CJKV_DEBUG_FNMAP { (*** exec _cjkv_CIDFontmapHandler for nametype: ) print dup == flush } if
+      /CIDFont findresource
+      /CIDFont defineresource pop
+    } bind
+    /stringtype {
+      CJKV_DEBUG_FNMAP { (*** exec _cjkv_CIDFontmapHandler for stringtype: \() print dup =only (\)\n) print flush } if
+      findlibfile {
+        CJKV_DEBUG_FNMAP { (*** exec _cjkv_CIDFontmapHandler found file\n) print } if
+        exch pop
+        % Define CIDFont with a name defined in the font file
+        CJKV_DEBUG_FNMAP { (***      _cjkv_CIDFontmapHandler->.cjkv_loadcidfontwithoutpop\n) print } if
+
+
+          CJKV_DEBUG_FNMAP { (.cjkv_loadcidfontwithoutpop start\n) print flush } if
+          dup 4 string .peekstring pop dup (ttcf) eq exch (\000\001\000\000) eq or {
+            .loadcjkvttcidfont
+          } {
+            /CIDFont /Category findresource /.Instances get
+            dup length 2 div cvi dict .copydict exch
+            .loadfont
+            /CIDFont /Category findresource /.Instances get {
+              2 index 2 index known {
+                pop pop
+              } {
+                pop exch pop /CIDFont findresource exit
+              } ifelse
+            } forall
+            dup /CIDFontName known not {
+              {Internal Error in .cjkv_loadcidfontwithoutpop} stop
+            } if
+          } ifelse
+          CJKV_DEBUG_FNMAP { (.cjkv_loadcidfontwithoutpop finished\n) print flush } if
+
+
+        CJKV_DEBUG_FNMAP { (***      _cjkv_CIDFontmapHandler<-.cjkv_loadcidfontwithoutpop\n) print } if
+        % Define CIDFont with a name define in CIDFontmap
+        dup length 0 ne {
+            dup /CIDFontName get 2 index eq {
+                CJKV_DEBUG_FNMAP { (*** define CIDFont resource with self name\n) print } if
+                % Avoid duplicated defineresource for the same CIDFont
+                pop pop
+            } {
+                CJKV_DEBUG_FNMAP { (*** rename CIDFont resource\n) print flush } if
+                % Give a name different from the name defined in the file
+                /CIDFont
+                CJKV_DEBUG_FNMAP { (*** exec defineresource: ) print 2 index == ( ) print 1 index == ( ) print 0 index == (\n) print flush } if
+                defineresource pop
+                CJKV_DEBUG_FNMAP { (*** exec defineresource ok\n) print flush } if
+            } ifelse
+        } {
+            CJKV_DEBUG_FNMAP { (*** 0-sized CIDFont dict\n) print } if
+            pop pop
+        } ifelse
+      } {
+        CJKV_DEBUG_FNMAP { (*** exec _cjkv_CIDFontmapHandler cannot find file\n) print } if
+        /undefinedresource signalerror
+      } ifelse
+      CJKV_DEBUG_FNMAP { (*** _cjkv_CIDFontmapHandler END\n) print } if
+    } bind
+    /arraytype {
+    % Replace filename in the array with file
+        dup 0 get
+        findlibfile {
+            3 1 roll pop
+            copyarray dup 3 1 roll 0
+            3 -1 roll put
+            % Expand array
+            aload pop .loadcjkvttcidfont
+            /CIDFont defineresource pop
+        } {
+            /undefinedresource signalerror
+        } ifelse
+    } bind
+  >> def
+
+
+  /.cjkv_CIDFontmapKnown {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnown: ) print flush dup == } if
+    userdict /_cjkv_CIDFontmap get
+    CJKV_DEBUG_FNMAP { dup { exch (    key: ) print == (        val: ) print == flush } forall } if
+    exch known
+  } bind def
+
+  /.cjkv_CIDFontmapKnownget {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnownget: ) print flush dup == } if
+    userdict /_cjkv_CIDFontmap get exch .knownget
+  } bind def
+
+  /.cjkv_CIDFontmapKnowngetBase {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnowngetBase: ) print flush dup == } if
+    userdict /_cjkv_CIDFontmap get exch { % dict key
+      1 index 1 index known {
+        CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnowngetBase: temp: ) print 1 index == flush } if
+        1 index exch get
+      } {
+        CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnowngetBase: base: ) print 1 index == flush } if
+        exit
+      } ifelse
+    } loop
+    exch pop
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapKnowngetBase: exit with ) print dup == flush } if
+  } bind def
+
+  /.cjkv_CIDFontmapRunHandler {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapRunHandler START\n) print flush } if
+    dup
+    /CIDFont /Category findresource /_cjkv_CIDFontmapHandler get
+    exch type get
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapRunHandler EXEC: _cjkv_CIDFontmapHandler:) print dup == flush } if
+    .execasresource
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapRunHandler END\n) print flush } if
+  } bind def
+
+  /.cjkv_CIDFontmapForAll {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapForAll\n) print flush } if
+    _cjkv_CIDFontmap exch forall
+  } bind def
+
+  /.cjkv_CIDFontmapForAllKey {
+    CJKV_DEBUG_FNMAP { (*** .cjkv_CIDFontmapForAllKey\n) print flush } if
+    [ /pop cvx 3 -1 roll /exec cvx ] cvx ._cjkv_CIDFontmapForAll
+  } bind def
+currentdict
+end
+
+
+%
+% CIDFont resource handler must be modified
+%
+languagelevel exch 2 .setlanguagelevel
+
+/CIDFont /Category findresource dup length dict .copydict
+copy
+  /.originalresourceforall 1 index /ResourceForAll get def
+
+  dup /ResourceForAll {
+    currentglobal false setglobal
+    [
+      4 index {cvn} 4 index .originalresourceforall {
+        dup length string cvs dup counttomark 4 add index
+        .stringmatch {
+          cvn counttomark -1 1 {
+            index 1 index eq {
+              pop exit % Duplicated
+            } if
+          } for
+        } {
+          pop
+        } ifelse
+      } .cjkv_CIDFontmapForAllKey
+    ]
+    exch setglobal
+    4 -1 roll pop 3 1 roll [
+      exch {cvs} aload pop 4 -1 roll aload pop
+    ] cvx
+    forall
+  } put
+
+  /.cjkv_loadcidfontresource {
+    CJKV_DEBUG_FNMAP { (.cjkv_loadcidfontresource\n) print flush } if
+    dup .ResourceFile {
+      {
+          CJKV_DEBUG_FNMAP { (.cjkv_loadcidfontwithoutpop start\n) print flush } if
+          dup 4 string .peekstring pop dup (ttcf) eq exch (\000\001\000\000) eq or {
+            .loadcjkvttcidfont
+          } {
+            /CIDFont /Category findresource /.Instances get
+            dup length 2 div cvi dict .copydict exch
+            .loadfont
+            /CIDFont /Category findresource /.Instances get {
+              2 index 2 index known {
+                pop pop
+              } {
+                pop exch pop /CIDFont findresource exit
+              } ifelse
+            } forall
+            dup /CIDFontName known not {
+              {Internal Error in .cjkv_loadcidfontwithoutpop} stop
+            } if
+          } ifelse
+          CJKV_DEBUG_FNMAP { (.cjkv_loadcidfontwithoutpop finished\n) print flush } if
+          pop
+
+      } .execasresource
+    } {
+      pop dup .cjkv_CIDFontmapKnownget {
+        .cjkv_CIDFontmapRunHandler
+      } {
+        dup /undefinedresource signalerror
+      } ifelse
+    } ifelse
+  } bind def
+
+  dup /.LoadResource {
+    CJKV_DEBUG_FNMAP { (.LoadResource\n) print flush } if
+    currentglobal {
+      .cjkv_loadcidfontresource
+    } {
+      true setglobal {.cjkv_loadcidfontresource} stopped false setglobal {stop} if
+    } ifelse
+  } bind put
+
+  dup /.ResourceFileStatus {
+    CJKV_DEBUG_FNMAP { (*** cjkv_modified .ResourceFileStatus for CIDFont\n) print flush } if
+    dup .cjkv_CIDFontmapKnown {
+      CJKV_DEBUG_FNMAP { (    ResourceFileStatus returns TRUE\n) print flush } if
+      pop 2 -1 true
+    } {
+      .ResourceFile {
+        CJKV_DEBUG_FNMAP { (    ResourceFileStatus returns TRUE\n) print flush } if
+        closefile 2 -1 true
+      } {
+        CJKV_DEBUG_FNMAP { (    ResourceFileStatus returns FALSE\n) print flush } if
+        pop false
+      } ifelse
+    } ifelse
+  } bind put
+
+  dup /.CIDFontmapKnown        { .cjkv_CIDFontmapKnown        } bind put
+  dup /.CIDFontmapKnownget     { .cjkv_CIDFontmapKnownget     } bind put
+  dup /.CIDFontmapKnowngetBase { .cjkv_CIDFontmapKnowngetBase } bind put
+  dup /.CIDFontmapRunHandler   { .cjkv_CIDFontmapRunHandler   } bind put
+  dup /.CIDFontmapForAll       { .cjkv_CIDFontmapForAll       } bind put
+  dup /.CIDFontmapForAllKey    { .cjkv_CIDFontmapForAllKey    } bind put
+
+/CIDFont exch /Category defineresource pop
+
+.setlanguagelevel
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/tt11util.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,708 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization
+%
+%
+% Based on gs-cjk patches
+% Copyright (C) 2001-2003 gs-cjk project:
+%   Taiji Yamada, Hideyuki Suzuki, Masatake Yamato and suzuki toshiya.
+%   Enhancements by Akira Tagoh and Taiji Yamada, 2005.
+%   All rights reserved.
+%
+%
+% Based on GNU Ghostscript 7.07 and 8.15
+% Copyright (C) 1996-2003 artofcode LLC.  All rights reserved.
+%
+% This software is provided AS-IS with no warranty, either express or
+% implied.
+%
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+
+[
+   /CJKV_DEBUG_TT11
+   /CJKV_DEBUG_OS2
+   /CJKV_DEBUG_GSUB
+] {dup where {pop pop} { currentdict exch false def pop } ifelse} forall
+
+% ---------------- CIDFontType 2 font loading ---------------- %
+
+/_cjkv_type11_tmp 15 dict def
+
+/_cjkv_type11_util 30 dict dup begin
+  
+  % Create a string with array of CIDs
+  % [ <cid1> ... <cidN> ] .cjkv_makecidmapstring <string>
+  /.cjkv_makecidmapstring {
+    CJKV_DEBUG_TT11 { (.cjkv_makecidmapstring\n) print flush } if
+    mark exch cvx exec counttomark                % mark 1..N len
+    dup 2 mul string                              % mark 1..N len s
+    dup 3 -1 roll 1 sub 2 mul -2 0 {              % mark 1..N s s
+      2 copy 5 index -8 bitshift put              % mark 1..N s s j2
+      1 add 4 -1 roll 16#ff and put dup           % mark 1..N-1 s s
+    } for pop                                     % mark s
+    exch pop                                      % s
+  } bind def
+  
+  % Create a string or an array of strings with array of CIDs
+  % [ <cid1> ... <cidN> ] .makecidmap <string>|[<string> ...]
+  %   written by Taiji Yamada <taiji@aihara.co.jp>
+  /.cjkv_makecidmap {
+    CJKV_DEBUG_TT11 { (.cjkv_makecidmap\n) print flush } if
+    dup length maxstring le {
+      _cjkv_type11_util /.cjkv_makecidmapstring get exec
+    } {
+      dup length dup maxstring idiv exch
+      maxstring mod 0 ne { 1 add } if array exch
+      0 1 3 index length 1 sub {
+        dup maxstring mul 1 index 1 add maxstring mul
+        3 index length .min 1 index sub
+        3 index 3 1 roll getinterval
+        _cjkv_type11_util /.cjkv_makecidmapstring get exec
+        3 index 3 1 roll put
+      } for pop
+    } ifelse
+  } bind def
+  
+  % <file> .cjkv_loadttcidfont <cidtype2font>
+  /.cjkv_loadttcidfont {
+    CJKV_DEBUG_TT11 { (+++ .cjkv_loadttcidfont\n) print flush } if
+    _cjkv_type42_util /.cjkv_loadttfonttables get exec
+    .cjkv_makesfnts
+          % CIDFontType2 fonts don't have a cmap: they are indexed by CID.
+    /.cjkv_ttencmapproc false def
+    mark
+    CJKV_DEBUG_TT11 { (+++ mark ok\n) print flush } if
+    .cjkv_ttkeys
+    CJKV_DEBUG_TT11 { (+++ .cjkv_ttkeys finished\n) print flush } if
+    .cjkv_definettcidfont
+    CJKV_DEBUG_TT11 { (+++ .cjkv_definettcidfont finished\n) print flush } if
+  } bind def
+  
+  % - .getgsub -
+  % Defines gsubh, gsubv, gsubh2v and also defines gsubver, gsubfmt
+  %   in the case that GSUB table has 'Single Substitution Format 2'
+  %   which is formally used for vertically oriented glyphs such as CJK fonts.
+  % Written by Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+  % Modified by Taiji Yamada <taiji@aihara.co.jp>
+  %
+  % [GSUB - The Glyph Substitution Table]
+  % Index        Size        Type        Name of Entry
+  % -----------------------------------
+  % 0        4        Fixed        Version
+  % 4        2        Offset        ScriptList
+  % 6        2        Offset        FeatureList
+  % 8        2        Offset        LookupList
+  %
+  % [Single Substitution Format 2, Subtable at LookupList]
+  % Index        Size        Type        Name of Entry
+  % -----------------------------------
+  % 0        2        uint16        SubstFormat
+  % 4        2        Offset        Coverage(--)
+  % 6        2        uint16        GlyphCount
+  % 8        2        GlyphID        Substitute(vertically oriented glyphs)
+  % --        2        uint16        SubstFormat
+  % +2        2        uint16        GlyphCount(same as above GlyphCount)
+  % +4        2        GlyphID        GlyphArray(horizontally oriented glyphs)
+  % -----------------------------------
+  % References
+  % 1. http://www.microsoft.com/typography/OTSPEC/gsub.htm
+  %
+  /.cjkv_getgsub {
+    CJKV_DEBUG_TT11 { (***   getgsub start\n) print } if
+    _cjkv_type11_tmp /gsubhog null put
+    _cjkv_type11_tmp /gsubvog null put
+    _cjkv_type11_tmp /gsubh2v null put
+    tabdict /GSUB .knownget { % if
+      CJKV_DEBUG_TT11 { (***      GSUB is known\n) print } if
+      dup /gsubver exch 0 .cjkv_getu32 _cjkv_type11_tmp 3 1 roll put
+      % dup /gsubosl exch 4 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+      % dup /gsubofl exch 6 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+      dup /gsuboll exch 8 .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+      CJKV_DEBUG_GSUB {
+        (gsubver: ) print _cjkv_type11_tmp /gsubver get =
+        % (gsubosl: ) print _cjkv_type11_tmp /gsubosl get =
+        % (gsubofl: ) print _cjkv_type11_tmp /gsubofl get =
+        (gsuboll: ) print _cjkv_type11_tmp /gsuboll get =
+      } if
+      % dup /gsubfmt exch _cjkv_type11_tmp /gsuboll get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+      dup /gsublc exch _cjkv_type11_tmp /gsuboll get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+      CJKV_DEBUG_GSUB {
+        (gsublc: ) print _cjkv_type11_tmp /gsublc get =
+        % (gsubfmt: ) print _cjkv_type11_tmp /gsubfmt get =
+      } if
+      _cjkv_type11_tmp /gsublc get 0 ne {
+        0 1 _cjkv_type11_tmp /gsublc get 1 sub {
+          2 mul /gsubolt exch 2 index exch _cjkv_type11_tmp /gsuboll get 2 add add .cjkv_getu16 _cjkv_type11_tmp /gsuboll get add _cjkv_type11_tmp 3 1 roll put
+          dup /gsubltype exch _cjkv_type11_tmp /gsubolt get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+          dup /gsublflag exch _cjkv_type11_tmp /gsubolt get 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+          dup /gsubsubc exch _cjkv_type11_tmp /gsubolt get 4 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+          CJKV_DEBUG_GSUB {
+            (gsubolt: ) print _cjkv_type11_tmp /gsubolt get =
+            (gsubltype: ) print _cjkv_type11_tmp /gsubltype get =
+            (gsublflag: ) print _cjkv_type11_tmp /gsublflag get =
+            (gsubsubc: ) print _cjkv_type11_tmp /gsubsubc get =
+          } if
+          _cjkv_type11_tmp /gsubsubc get 0 ne {
+            0 1 _cjkv_type11_tmp /gsubsubc get 1 sub {
+              2 mul /gsubost exch 2 index exch _cjkv_type11_tmp /gsubolt get 6 add add .cjkv_getu16 _cjkv_type11_tmp /gsubolt get add _cjkv_type11_tmp 3 1 roll put
+              dup /substfmt exch _cjkv_type11_tmp /gsubost get 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+              CJKV_DEBUG_GSUB {
+                (gsubost: ) print _cjkv_type11_tmp /gsubost get =
+                (substfmt: ) print _cjkv_type11_tmp /substfmt get =
+              } if
+  %           _cjkv_type11_tmp /gsubver get 16#00010000 eq { % ifelse
+              _cjkv_type11_tmp /gsubltype get 1 eq _cjkv_type11_tmp /substfmt get 2 eq and { % ifelse
+                dup /gsubocv exch _cjkv_type11_tmp /gsubost get 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                dup /gsubglc exch _cjkv_type11_tmp /gsubost get 4 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                % hacked by suzuki toshiya at 2001/3/6
+                %dup /gsubvog exch _cjkv_type11_tmp /gsubost get 6 add _cjkv_type11_tmp /gsubglc get getinterval _cjkv_type11_tmp 3 1 roll put
+                %dup /gsubhog exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 4 add _cjkv_type11_tmp /gsubglc get getinterval _cjkv_type11_tmp 3 1 roll put
+                dup /gsubvog exch _cjkv_type11_tmp /gsubost get 6 add _cjkv_type11_tmp /gsubglc get 2 mul getinterval _cjkv_type11_tmp 3 1 roll put
+                dup /cvfmt exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 0 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                dup /cvglc exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 2 add .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                dup /gsubhog exch _cjkv_type11_tmp /gsubost get _cjkv_type11_tmp /gsubocv get add 4 add _cjkv_type11_tmp /cvglc get 2 mul getinterval _cjkv_type11_tmp 3 1 roll put
+                CJKV_DEBUG_GSUB {
+                  (gsubocv: ) print _cjkv_type11_tmp /gsubocv get =
+                  (gsubglc: ) print _cjkv_type11_tmp /gsubglc get =
+                  (cvfmt: ) print _cjkv_type11_tmp /cvfmt get =
+  
+                  (gsubhog->gsubvog ) =
+                  0 2 _cjkv_type11_tmp /gsubhog get length 2 sub { % for
+                    dup
+                    _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 =only
+                    (->) =only
+                    _cjkv_type11_tmp /gsubvog get exch .cjkv_getu16 =
+                  } for
+                } if
+                _cjkv_type11_tmp /cvfmt get 1 eq {
+                  /gsubh2v << 0 2 _cjkv_type11_tmp /gsubhog get length 2 sub {
+                    dup _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16
+                    exch _cjkv_type11_tmp /gsubvog get exch .cjkv_getu16
+                  } for >> _cjkv_type11_tmp 3 1 roll put
+                } {
+                  _cjkv_type11_tmp /cvfmt get 2 eq {
+                    /gsubh2v << 0 6 _cjkv_type11_tmp /gsubhog get length 6 sub {
+                      dup 0 add /fgid exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                      dup 2 add /lgid exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                      4 add /cvidx exch _cjkv_type11_tmp /gsubhog get exch .cjkv_getu16 _cjkv_type11_tmp 3 1 roll put
+                      CJKV_DEBUG_GSUB {
+                        (fgid: ) print _cjkv_type11_tmp /fgid get =
+                        (lgid: ) print _cjkv_type11_tmp /lgid get =
+                        (cvidx: ) print _cjkv_type11_tmp /cvidx get =
+                      } if
+                      _cjkv_type11_tmp /fgid get 1 _cjkv_type11_tmp /lgid get {
+                        dup _cjkv_type11_tmp /cvidx get add _cjkv_type11_tmp /fgid get sub
+                        exch _cjkv_type11_tmp /gsubvog get exch .cjkv_getu16
+                      } for
+                    } for >> _cjkv_type11_tmp 3 1 roll put
+                  } {
+                    %(UNKNWON COVERAGE FORMAT.) = flush
+                  } ifelse
+                } ifelse
+              } {
+                %(UNKNOWN GSUB FORMAT.) = flush
+              } ifelse
+  %           } {
+  %             (ILLEGAL GSUB VERSION.) = flush
+  %           } ifelse
+            } for
+          } if
+        } for
+      } if
+      pop
+    } if
+  } bind def
+  
+  % glyphid .gsublookup glyphid
+  % Lookup substitute table. return the origin if not found.
+  %   modified by Taiji Yamada <taiji@aihara.co.jp> and Hideyuki Suzuki
+  /.gsublookup {
+    CJKV_DEBUG_TT11 { (.gsublookup\n) print flush } if
+    dup _cjkv_type11_tmp /gsubh2v get exch .knownget { exch pop } if
+  } bind def
+  
+  % - .cjkv_getos2 -
+  % Defines os2ver, os2cp1, os2cp2
+  %   to detect the kind of CID with the OS/2 table of a TrueType font.
+  % Written by Taiji Yamada <taiji@aihara.co.jp>
+  %
+  % [OS/2 - OS/2 and Windows Metrics]
+  % Index        Size        Type        Name of Entry
+  % -----------------------------------
+  % 0        2        USHORT        version
+  % 2        2        SHORT        xAvgCharWidth
+  % 4        2        USHORT        usWeightClass
+  % 6        2        USHORT        usWidthClass
+  % 8        2        SHORT        fsType
+  % 10        2        SHORT        ySubscriptXSize
+  % 12        2        SHORT        ySubscriptYSize
+  % 14        2        SHORT        ySubscriptXOffset
+  % 16        2        SHORT        ySubscriptYOffset
+  % 18        2        SHORT        ySuperscriptXSize
+  % 20        2        SHORT        ySuperscriptYSize
+  % 22        2        SHORT   ySuperscriptXOffset
+  % 24        2        SHORT        ySuperscriptYOffset
+  % 26        2        SHORT        yStrikeoutSize
+  % 28        2        SHORT        yStrikeoutPosition
+  % 30        2        SHORT        sFamilyClass
+  % 32        10        BYTE        panose[10]
+  % 42        4        ULONG        ulUnicodeRange1
+  % 46        4        ULONG        ulUnicodeRange2
+  % 50        4        ULONG        ulUnicodeRange3
+  % 54        4        ULONG        ulUnicodeRange4
+  % 58        4        CHAR        achVendID[4]
+  % 62        2        USHORT        fsSelection
+  % 64        2        USHORT        usFirstCharIndex
+  % 66        2        USHORT        usLastCharIndex
+  % 68        2        SHORT        sTypoAscender
+  % 70        2        SHORT        sTypoDescender
+  % 72        2        SHORT        sTypoLineGap
+  % 74        2        USHORT        usWinAscent
+  % 76        2        USHORT        usWinDescent
+  % 78        4        ULONG        ulCodePageRange1
+  % 82        4        ULONG        ulCodePageRange2
+  % 86        2        SHORT        sxHeight
+  % 88        2        SHORT        sCapHeight
+  % 90        2        USHORT        usDefaultChar
+  % 92        2        USHORT        usBreakChar
+  % 94        2        USHORT        usMaxContext
+  % -----------------------------------
+  % References
+  % 1. http://www.microsoft.com/typography/OTSPEC/os2.htm
+  %
+  /.cjkv_getos2 {
+    CJKV_DEBUG_TT11 { (.cjkv_getos2\n) print flush } if
+    /os2ver 0 def
+    tabdict (OS/2) cvn .knownget { % if
+      dup /os2ver exch 0 .cjkv_getu16 def
+      os2ver 0 gt { % if
+        %dup /os2typ exch 8 .cjkv_gets16 def
+        %dup /os2fam exch 30 .cjkv_gets16 def
+        dup /os2ur1 exch 42 .cjkv_getu32 def
+        dup /os2ur2 exch 46 .cjkv_getu32 def
+        dup /os2ur3 exch 50 .cjkv_getu32 def
+        dup /os2ur4 exch 54 .cjkv_getu32 def
+        %dup /os2sel exch 62 .cjkv_getu16 def
+        %dup /os2fci exch 64 .cjkv_getu16 def
+        %dup /os2lci exch 64 .cjkv_getu16 def
+        dup /os2cp1 exch 78 .cjkv_getu32 def 
+        dup /os2cp2 exch 82 .cjkv_getu32 def
+        CJKV_DEBUG_OS2 {
+          /tmp 64 string def
+          (os2ver: ) print os2ver 2 tmp cvrs =
+          %(os2typ: ) print os2typ 2 tmp cvrs =
+          %(os2fam: ) print os2fam 2 tmp cvrs =
+          (os2ur1: ) print os2ur1 2 tmp cvrs =
+          (os2ur2: ) print os2ur2 2 tmp cvrs =
+          (os2ur3: ) print os2ur3 2 tmp cvrs =
+          (os2ur4: ) print os2ur4 2 tmp cvrs =
+          %(os2sel: ) print os2sel 2 tmp cvrs =
+          %(os2fci: ) print os2fci 2 tmp cvrs =
+          %(os2lci: ) print os2lci 2 tmp cvrs =
+          (os2cp1: ) print os2cp1 2 tmp cvrs =
+          (os2cp2: ) print os2cp2 2 tmp cvrs =
+          [
+            [ 1 0 bitshift (Latin 1)        ]
+            [ 1 1 bitshift (Latin 2)        ]
+            [ 1 2 bitshift (Cyrillic)        ]
+            [ 1 3 bitshift (Greek)        ]
+            [ 1 4 bitshift (Turkish)        ]
+            [ 1 5 bitshift (Hebrew)        ]
+            [ 1 6 bitshift (Arabic)        ]
+            [ 1 7 bitshift (Baltic)        ]
+            [ 1 8 bitshift (Vietnamese)        ]
+            [ 1 16 bitshift (Thai)        ]
+            [ 1 17 bitshift (Japanese)        ]
+            [ 1 18 bitshift (Simplified Chinese)        ]
+            [ 1 19 bitshift (Korean Wansung)        ]
+            [ 1 20 bitshift (Traditional Chinese)        ]
+            [ 1 21 bitshift (Korean Johab)        ]
+            [ 1 31 bitshift (Symbol)        ]
+          ] { % forall
+            dup 0 get os2cp1 and 0 gt { % if
+              (CodePage: ) print 1 get =
+            } {
+                pop
+            } ifelse
+          } forall
+        } if
+      } if
+      pop
+    } if
+  } bind def
+  
+  % ---------------- CJK TrueType font loading ---------------- %
+  
+  % Written by the gs-cjk project
+  
+  % .parsecmap
+  % push an array as a result of reading a CMap file.
+  % the array is of the following form.
+  %   [ [ [ dst src num ] [ dst src num ] ... [ dst src num ] ]
+  %     [ [ dst src num ] [ dst src num ] ... [ dst src num ] ]
+  %     ...
+  %     [ [ dst src num ] [ dst src num ] ... [ dst src num ] ] ]
+  % each array [dst src num] corresponds to each line within
+  % /begin{bf,cid}{char,range}/end{bf,cid}{char,range} pairs.
+  
+  /.parsecmapdict mark
+  
+    CJKV_DEBUG_TT11 { (.parsecmapdict\n) print flush } if
+    % override system operators
+    /findresource { pop } bind
+    /defineresource { pop pop } bind
+    /dict {}
+    /def { pop pop } bind
+    /dup null
+    /begin { pop } bind
+    /end {}
+    /currentdict null
+  
+    % override CMap operators
+    /usecmap { pop } bind
+    /CMapName null
+    /begincmap { [ } bind
+    /endcmap { ] } bind
+    /begincodespacerange { pop mark } bind
+    /endcodespacerange { cleartomark } bind
+    /beginnotdefrange { pop mark } bind
+    /endnotdefrange { cleartomark } bind
+    /beginbfchar { /parsecmapcounter exch def } bind        % for FromCID CMaps
+    /endbfchar {
+      parsecmapcounter dup array exch 1 sub -1 0 {
+        [ 5 3 roll exch .cjkv_strtoint 1 ]
+        2 index 3 1 roll put
+      } for
+    } bind
+    /beginbfrange { begincidrange }                       % for FromCID CMaps
+    /endbfrange { endcidrange }
+    /begincidchar { beginbfchar }                                % for ToCID CMaps
+    /endcidchar { endbfchar }
+    /begincidrange { /parsecmapcounter exch def } bind        % for ToCID CMaps
+    /endcidrange {
+      parsecmapcounter dup array exch 1 sub -1 0 {
+        [ 6 3 roll 3 1 roll .cjkv_strtoint exch .cjkv_strtoint exch 1 index sub 1 add ]
+        2 index 3 1 roll put
+      } for
+    } bind
+  
+    % misc
+    /parsecmapcounter 0
+  
+  .dicttomark def         % .parsecmapdict
+  
+  
+  /.parsecmapfname 100 string def
+  
+  % <CMapName> .parsecmap <array>
+  % Return the contents of the CMap.  If the CMap is not found, empty array
+  % is returned.  Note that usecmap is ignored because of efficiency.
+  /.parsecmap {
+    CJKV_DEBUG_TT11 { (.parsecmap\n) print flush } if
+    /CMap /Category findresource begin
+    //.parsecmapfname ResourceFileName end        % filename
+    dup status {
+      pop pop pop pop
+      _cjkv_type11_util /.parsecmapdict get begin run end
+    } {
+      pop []
+    } ifelse
+  } bind def
+  
+  % .cjkv_buildcmaptab
+  % construct a cmap table using information obtained from horizontal/vertical
+  % CMaps, ToUnicode CMap, and substition data.
+  
+  % cmap /CMap proc .applyCMap cmap
+  /.applyCMap {
+    CJKV_DEBUG_TT11 { (.applyCMap\n) print flush } if
+    exch _cjkv_type11_util /.parsecmap get exec                        % {} [[[].].]
+    dup length 1 sub -1 0 {                % {} [[[].].] len-1 -1 0 {} for
+      1 index exch get                        % {} [[[].].] [[].]
+      dup length 1 sub -1 0 {                % {} [[[].].] [[].] len-1 -1 0 for {}
+        1 index exch get                        % {} [[[].].] [[].] [ cid gid num ]
+        cvx exec cmapglyphs                % {} [[[].].] [[].] cid gid num gmap
+        3 1 roll .cjkv_safegetinterval {        % {} [[[].].] [[].] cid [gid'..]
+          4 index exec dup cmapglyphs 0 get eq 1 index 0 eq or {
+            % found no glyph
+            pop
+          } {
+            % found a glyph
+            5 index exch 2 index exch .cjkv_safeput
+          } ifelse
+          1 add                                % {} [[[].].] [[].] cid++
+        } forall pop
+      } for                                % {} [[[].].] [[].]
+      pop                                        % {} [[[].].]
+    } for                                        % {} [[[].].]
+    pop pop                                %
+  } bind def
+  
+  % cmap /CMap-V .applyvCMap cmap
+  /.applyvCMap {
+    CJKV_DEBUG_TT11 { (.applyvCMap\n) print flush } if
+    _cjkv_type11_tmp /gsubh2v get null ne {
+      { _cjkv_type11_util /.gsublookup get exec } _cjkv_type11_util /.applyCMap get exec
+    } {
+      { } _cjkv_type11_util /.applyCMap get exec
+    } ifelse
+  } bind def
+  
+  % cmap /CMap-H .applyhCMap cmap
+  /.applyhCMap {
+    CJKV_DEBUG_TT11 { (.applyhCMap\n) print flush } if
+    { } _cjkv_type11_util /.applyCMap get exec
+  } bind def
+  
+  % cmap /CMap-V .applyvCMapUnicode cmap
+  /.applyvCMapUnicode {
+    CJKV_DEBUG_TT11 { (.applyvCMapUnicode\n) print flush } if
+    _cjkv_type11_tmp /gsubh2v get null ne {
+      {
+        dup 16#f900 ge
+        1 index 16#ff00 ge 2 index 16#ff9f le and not
+        and not {
+          _cjkv_type11_util /.gsublookup get exec
+        } if
+      } bind _cjkv_type11_util /.applyCMap get exec
+    } {
+      { } _cjkv_type11_util /.applyCMap get exec
+    } ifelse
+  } bind def
+  
+  % cmap /Adobe-*-* .applyCIDToCode cmap
+  /.applyCIDToCode {
+    CJKV_DEBUG_TT11 { (.applyCIDToCode\n) print flush } if
+    _cjkv_type11_util /.parsecmap get exec
+    {
+      {                           % cmap [ dist cid num ]
+        dup 0 get length 2 gt {   % multi-byte dist is not supported yet.
+          pop
+        } {
+          cvx exec exch           % cmap dist num cid
+          cmapglyphs 4 2 roll     % cmap cid cmapglyphs dist num
+          exch .cjkv_strtoint exch
+          .cjkv_safegetinterval        % cmap cid subcmapglyphs
+          {                       % cmap cid gid
+            2 index 2 index       % cmap cid gid cmap cid
+            3 2 roll              % cmap cid cmap cid gid
+            .cjkv_safeput              % cmap cid
+            1 add                 % cmap nextcid
+          } forall pop
+        } ifelse
+      } forall
+    } forall
+  } bind def
+  
+  % cmap /Adobe-*-UCS2 .applyCIDToUnicode cmap
+  /.applyCIDToUnicode {
+    CJKV_DEBUG_TT11 { (.applyCIDToUnicode\n) print flush } if
+    _cjkv_type11_util /.parsecmap get exec
+    {
+      {                           % cmap [ distuni cid num ]
+        dup 0 get length 2 gt     % multi-byte dist is not supported yet.
+        1 index 0 get <fffd> eq   % the value <fffd> is regard as undefined code.
+        or {
+          pop
+        } {
+          cvx exec exch           % cmap distuni num cid
+          cmapglyphs 4 2 roll     % cmap cid cmapglyphs distuni num
+          exch .cjkv_strtoint exch     % cmap cid cmapglyphs distuni num
+          .cjkv_safegetinterval        % cmap cid subcmapglyphs
+          {                       % cmap cid gid
+            2 index 2 index       % cmap cid gid cmap cid
+            3 2 roll              % cmap cid cmap cid gid
+            .cjkv_safeput              % cmap cid
+            1 add                 % cmap nextcid
+          } forall pop
+        } ifelse
+      } forall
+    } forall
+  } bind def
+  
+  /.cjkv_buildcmapdict mark
+    /Adobe-CNS1 <<
+      /Registry (Adobe)
+      /Ordering (CNS1)
+      /CIDCounts [ 14099 17408 17601 18846 18962 ]
+      /Big5 { 0 {
+        /Adobe-CNS1-ETen-B5     _cjkv_type11_util /.applyCIDToCode    get exec
+        /ETen-B5-V              _cjkv_type11_util /.applyvCMap        get exec
+        /ETen-B5-H              _cjkv_type11_util /.applyhCMap        get exec
+      } }
+      /Unicode { 3 {
+        /Adobe-CNS1-UCS2        _cjkv_type11_util /.applyCIDToUnicode get exec
+        /UniCNS-UCS2-V          _cjkv_type11_util /.applyvCMapUnicode get exec
+        /UniCNS-UCS2-H          _cjkv_type11_util /.applyhCMap        get exec
+      } }
+    >>
+    /Adobe-GB1 <<
+      /Registry (Adobe)
+      /Ordering (GB1)
+      /CIDCounts [ 7717 9897 22127 22353 29064 ]
+      /PRC { 2 {
+        /Adobe-GB1-GBK-EUC      _cjkv_type11_util /.applyCIDToCode    get exec
+        /GBK-EUC-V              _cjkv_type11_util /.applyvCMap        get exec
+        /GBK-EUC-H              _cjkv_type11_util /.applyhCMap        get exec
+      } }
+      /Unicode { 4 {
+        /Adobe-GB1-UCS2         _cjkv_type11_util /.applyCIDToUnicode get exec
+        /UniGB-UCS2-V           _cjkv_type11_util /.applyvCMapUnicode get exec
+        /UniGB-UCS2-H           _cjkv_type11_util /.applyhCMap        get exec
+      } }
+    >>
+    /Adobe-Japan1 <<
+      /Registry (Adobe)
+      /Ordering (Japan1)
+      /CIDCounts [ 8284 8359 8720 9354 15444 20317 23058 ]
+      /ShiftJIS { 2 {
+        /Adobe-Japan1-90ms-RKSJ _cjkv_type11_util /.applyCIDToCode    get exec
+        /90ms-RKSJ-V            _cjkv_type11_util /.applyvCMap        get exec
+        /90ms-RKSJ-H            _cjkv_type11_util /.applyhCMap        get exec
+      } }
+      /Unicode { 4 {
+        /Adobe-Japan1-UCS2      _cjkv_type11_util /.applyCIDToUnicode get exec
+        /UniJIS-UCS2-V          _cjkv_type11_util /.applyvCMapUnicode get exec
+        /UniJIS-UCS2-H          _cjkv_type11_util /.applyhCMap        get exec
+      } }
+    >>
+    /Adobe-Japan2 <<
+      /Registry (Adobe)
+      /Ordering (Japan2)
+      /CIDCounts [ 6068 ]
+      /Unicode { 0  {
+        /UniHojo-UCS2-V         _cjkv_type11_util /.applyvCMapUnicode get exec
+        /UniHojo-UCS2-H         _cjkv_type11_util /.applyhCMap        get exec
+      } }
+    >>
+    /Adobe-Korea1 <<
+      /Registry (Adobe)
+      /Ordering (Korea1)
+      /CIDCounts [ 9333 18155 18352 ]
+      /Johab { 1 {
+        /KSC-Johab-V            _cjkv_type11_util /.applyvCMap        get exec
+        /KSC-Johab-H            _cjkv_type11_util /.applyhCMap        get exec
+      } }
+      /Unicode { 2 {
+        /Adobe-Korea1-UCS2      _cjkv_type11_util /.applyCIDToUnicode get exec
+        /UniKS-UCS2-V           _cjkv_type11_util /.applyvCMapUnicode get exec
+        /UniKS-UCS2-H           _cjkv_type11_util /.applyhCMap        get exec
+      } }
+      /Wansung { 1 {
+        /Adobe-Korea1-KSCms-UHC _cjkv_type11_util /.applyCIDToCode    get exec
+        /KSCms-UHC-V            _cjkv_type11_util /.applyvCMap        get exec
+        /KSCms-UHC-H            _cjkv_type11_util /.applyhCMap        get exec
+      } }
+    >>
+    /Identity <<        % ttcmap ordering CIDMap only for specific and rare CJK TTF
+      /Registry (Unregistered)        % Thus Registry value is unpredictable. This
+      /Ordering (Identity)        % CIDFont can be used with Identity-H|V CMap
+      /CIDCounts [ 65535 ]
+      /H { 0 {
+        /Identity-H             _cjkv_type11_util /.applyhCMap        get exec % for ttcmap-order CIDMap
+      } }
+      /V { 0 {
+        /Identity-H             _cjkv_type11_util /.applyvCMap        get exec % for ttcmap-order and vertically-used CIDMap
+      } }
+    >>
+  .dicttomark def
+  
+  /.cjkv_ttencmap <<
+    /Identity              false
+    /Auto                  { 
+                             CJKV_DEBUG_TT11 { (+++ ttencmap->Auto exec\n) print flush } if
+                             _cjkv_type11_util /.cjkv_ttencoding get exec {
+                               dup
+                               _cjkv_type11_util /.cjkv_ttcharset get
+                               exch get
+                             CJKV_DEBUG_TT11 { (+++                exec\n) print flush } if
+                               exec
+                             CJKV_DEBUG_TT11 { (+++                      ok\n) print flush } if
+                               exch true
+                             } {
+                               false
+                             } ifelse
+                           } bind
+    /Adobe-CNS1            { /Adobe-CNS1   _cjkv_type11_util /.cjkv_ttencoding get exec }
+    /Adobe-GB1             { /Adobe-GB1    _cjkv_type11_util /.cjkv_ttencoding get exec }
+    /Adobe-Japan1          { /Adobe-Japan1 _cjkv_type11_util /.cjkv_ttencoding get exec }
+    /Adobe-Japan2          { /Adobe-Japan2 _cjkv_type11_util /.cjkv_ttencoding get exec }
+    /Adobe-Korea1          { /Adobe-Korea1 _cjkv_type11_util /.cjkv_ttencoding get exec }
+    /Adobe-CNS1-Big5       { /Adobe-CNS1   /Big5     true }
+    /Adobe-CNS1-Unicode    { /Adobe-CNS1   /Unicode  true }
+    /Adobe-GB1-PRC         { /Adobe-GB1    /PRC      true }
+    /Adobe-GB1-Unicode     { /Adobe-GB1    /Unicode  true }
+    /Adobe-Japan1-ShiftJIS { /Adobe-Japan1 /ShiftJIS true }
+    /Adobe-Japan1-Unicode  { /Adobe-Japan1 /Unicode  true }
+    /Adobe-Japan2-Unicode  { /Adobe-Japan2 /Unicode  true }
+    /Adobe-Korea1-Johab    { /Adobe-Korea1 /Johab    true }
+    /Adobe-Korea1-Unicode  { /Adobe-Korea1 /Unicode  true }
+    /Adobe-Korea1-Wansung  { /Adobe-Korea1 /Wansung  true }
+    /Identity-H            { /Identity     /H        true }
+    /Identity-V            { /Identity     /V        true }
+  >> def
+  
+  /.cjkv_ttcharset <<
+    /Unicode  { _cjkv_type11_util /.cjkv_detectos2 get exec }
+    /ShiftJIS /Adobe-Japan1
+    /Big5     /Adobe-CNS1
+    /PRC      /Adobe-GB1
+    /Wansung  /Adobe-Korea1
+    /Johab    /Adobe-Korea1
+  >> def
+  
+  /.cjkv_ttencdict <<
+    <00030001> /Unicode
+    <00030002> /ShiftJIS
+    <00030003> /Big5
+    <00030004> /PRC
+    <00030005> /Wansung
+    <00030006> /Johab
+  >> def
+  
+  /.cjkv_ttencoding {
+    CJKV_DEBUG_TT11 { (.cjkv_ttencoding\n) print flush } if
+    _cjkv_type11_util /.cjkv_ttencdict get _cjkv_ttcmap_tmp /cmapsub get 0 4 getinterval .knownget
+  } bind def
+  
+  /.cjkv_ttos2tab [
+    [ 1 20 bitshift /Adobe-CNS1   ]
+    [ 1 18 bitshift /Adobe-GB1    ]
+    [ 1 17 bitshift /Adobe-Japan1 ]
+    [ 1 19 bitshift /Adobe-Korea1 ]
+    [ 1 21 bitshift /Adobe-Korea1 ]
+  ] def
+  
+  /.cjkv_detectos2 {
+    CJKV_DEBUG_TT11 { (.cjkv_detectos2\n) print flush } if
+    /Identity        % default linear ordering to GID, Adobe Identity CIDs
+    os2ver 0 gt {
+      _cjkv_type11_util /.cjkv_ttos2tab get {
+        dup 0 get os2cp1 and 0 ne {
+          1 get exch
+        } if pop
+      } forall
+    } if
+  } bind def
+
+end readonly def
--- /dev/null	2006-10-03 09:23:15.605078000 +0100
+++ espgs-8.15.2/lib/cjkv/cjkvinit.ps	2006-10-03 15:16:07.000000000 +0100
@@ -0,0 +1,46 @@
+%!
+%
+% Developed by AXE,Inc., BBR Inc. and Turbolinux Inc.
+%   under the technical advice by suzuki toshiya (Hiroshima University)
+% For questions, please send mail to espgs8-cjk@printing-japan.org
+%
+% (C) Copyright 2006 Center of the International Cooperation for
+%     Computerization 
+%
+% This program is free software;  you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+% See the GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software Foundation,
+% Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+%
+
+/CJKV_DEBUG dup where {
+  pop pop
+  currentdict
+  [
+    /CJKV_DEBUG_BASE
+    /CJKV_DEBUG_CIDCM
+    /CJKV_DEBUG_FNMAP
+    /CJKV_DEBUG_TTCF
+    /CJKV_DEBUG_TT11
+    /CJKV_DEBUG_TT42
+    /CJKV_DEBUG_GSUB
+%   /CJKV_DEBUG_OS2	% fragile
+  ] { true def } forall
+} if
+pop
+
+(cjkv/baseutil.ps) runlibfile
+(cjkv/tt42util.ps) runlibfile
+(cjkv/tt11util.ps) runlibfile
+(cjkv/cjkvttcf.ps) runlibfile
+(cjkv/cjkfnmap.ps) runlibfile
+(cjkv/cjkcidcm.ps) runlibfile
--- espgs-8.15.2/lib/gs_ttf.ps.cjkv	2006-10-03 15:16:07.000000000 +0100
+++ espgs-8.15.2/lib/gs_ttf.ps	2006-10-03 15:16:07.000000000 +0100
@@ -568,19 +568,12 @@
   (name) 1 index
   (OS/2) 1 index
   (post) { .readbigtable }
-  %(vhea) 1 index
-  systemdict /DEVICE .knownget { (pdfwrite) ne } {true} ifelse {
-  (vhea) 1 index  % better to be ignored for vertical writing in pdfwrite
-  } if
-  (mort) 1 index  % for WMode glyph substitution
+  (vhea) 1 index
 	% Big tables
   (glyf) { .readbigtable }
   (loca) 1 index
   (hmtx) 1 index
-  %(vmtx) 1 index
-  systemdict /DEVICE .knownget { (pdfwrite) ne } {true} ifelse {
-  (vmtx) 1 index  % better to be ignored for vertical writing in pdfwrite
-  } if
+  (vmtx) 1 index
 	% Tables only needed for embedding in PDF files
   (cvt ) { .readtable }
   (fpgm) 1 index
--- espgs-8.15.2/lib/gs_init.ps.in	2006-11-16 17:34:11.000000000 +0000
+++ ../devel/espgs-8.15.3/lib/gs_init.ps.in	2006-08-26 01:53:04.000000000 +0100
@@ -148,6 +148,7 @@
 currentdict /NOFONTMAP known   /NOFONTMAP exch def
 currentdict /NOFONTPATH known   /NOFONTPATH exch def
 currentdict /NOGC known   /NOGC exch def
+currentdict /NOCJKV known   /NOCJKV exch def
 currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if
 currentdict /NOMEDIAATTRS known /NOMEDIAATTRS exch def
 currentdict /NOOUTERSAVE known   /NOOUTERSAVE exch def
@@ -2247,4 +2248,9 @@
   { NOOUTERSAVE not { save pop } if }	% do the outermost save unless disabled
 ifelse
 
+%Load CJKV environment.
+NOCJKV not {
+  (cjkv/cjkvinit.ps) runlibfile
+} if
+
 % The interpreter will run the initial procedure (start).