Bug 689646

Summary: vertical text rendered by external CIDFontType0 flows horizontal
Product: Ghostscript Reporter: mpsuzuki <mpsuzuki>
Component: TextAssignee: mpsuzuki <mpsuzuki>
Status: NOTIFIED FIXED    
Severity: major CC: mpsuzuki
Priority: P4    
Version: master   
Hardware: PC   
OS: All   
Customer: Word Size: ---
Bug Depends on:    
Bug Blocks: 689464    
Attachments: sample of simple vertical CJK text, requires free CIDFont: WadaGo-Bold
png16 output by SVN revision 5606
png16 output by SVN revision 5607
png16 output by latest (SVN revision 8482)
Reference output by Adobe Acrobat
PS file draw vertical text with CIDFontType0 including "nop"-like CDevProc
Acrobat Distiller output of sample PS file #3736
Patch to restrict unwanted CDevProc application

Description mpsuzuki 2008-01-09 20:05:47 UTC
By Igor's changeset at SVN r5607 (gs-8.5x), vertical CJK text
rendered by external CIDFontType0 flows horizontal instead of vertical.

This bug is not related with glyph cache, -dNOCACHE generates
completely same error. This bug is visible when output device
is raster: I've not checked all raster device but found in png16
and x11. This bug is invisible when output device is x11alpha.
Comment 1 mpsuzuki 2008-01-09 20:07:33 UTC
Created attachment 3683 [details]
sample of simple vertical CJK text, requires free CIDFont: WadaGo-Bold
Comment 2 mpsuzuki 2008-01-09 20:08:42 UTC
Created attachment 3684 [details]
png16 output by SVN revision 5606

SVN revision 5606 renders well.
Comment 3 mpsuzuki 2008-01-09 20:09:48 UTC
Created attachment 3685 [details]
png16 output by SVN revision 5607

since SVN revision 5607, the vertical text flows horizontal.
Comment 4 mpsuzuki 2008-01-09 20:11:21 UTC
Created attachment 3686 [details]
png16 output by latest (SVN revision 8482)

SVN HEAD 8482 has same bug.
Comment 5 mpsuzuki 2008-01-09 20:15:16 UTC
Created attachment 3687 [details]
Reference output by Adobe Acrobat

Reference output by Adobe Acrobat.

To render the sample PostScript by Adobe Acrobat with WadaGo-Bold,
you should install WadaGo-Bold font file into the directory:
C:\Program Files\Adobe\Acrobat ?.?\Resource\CIDFont\
Comment 6 Ray Johnston 2008-01-15 09:40:08 UTC
I'm assuming that mpsuzuki overlooked the default assignment to 'support'
Comment 7 mpsuzuki 2008-01-24 08:19:17 UTC
Created attachment 3736 [details]
PS file draw vertical text with CIDFontType0 including "nop"-like CDevProc

Modified sample file that inserts "nop"-like CDevProc to genuine CIDFontType 0
and tries to draw vertical texts.
Comment 8 mpsuzuki 2008-01-24 08:21:46 UTC
Created attachment 3737 [details]
Acrobat Distiller output of sample PS file #3736

Acrobat Distiller output of modified sample file #3736,
which inserts "nop"-like CDevProc to genuine CIDFontType0
and tries to draw vertical text. The text flows horizontally.
Comment 9 mpsuzuki 2008-01-24 08:25:47 UTC
Created attachment 3738 [details]
Patch to restrict unwanted CDevProc application

Igor's changeset SVN revision 5607 is the application of
CDevProc in any case. If I insert "nop"-like CDevProc to
genuine CIDFont dictionary aslike:

	/HeiseiMin-W5 /CIDFont findresource
	dup length 1 add dict copy
	dup /CIDFontName /HeiseiMin-W5-Fix put
	% just pop CID and keep metric infos as they are
	dup /CDevProc { pop } put
	dup /CIDFontName get exch /CIDFont defineresource

the PDF generated by Adobe Distiller shows text flowing horizontal.

It seems that this bug is "correct" behaviour when unwanted
CDevProc is applied. If I restrict the application of CDevProc
to the case CDevProc is explicitly defined, this bug (vertical
text flowing horizontally) is fixed.

Index: src/zchar1.c
===================================================================
--- src/zchar1.c	(revision 8487)
+++ src/zchar1.c	(working copy)
@@ -299,7 +299,16 @@
					    &other_subr);
	    case type1_result_sbw:	/* [h]sbw, just continue */
		if (cxs.present != metricsSideBearingAndWidth)
-		    type1_cis_get_metrics(pcis, cxs.sbw);
+		{
+		    ref *pcdevproc;
+		    if (zchar_get_CDevProc((const gs_font_base *)pfont,
+					    &pcdevproc))
+			type1_cis_get_metrics(pcis, cxs.sbw);
+		    else if (!cxs.use_FontBBox_as_Metrics2)
+			type1_cis_get_metrics(pcis, cxs.sbw);
+		    else
+			cxs.present = metricsSideBearingAndWidth;
+		}
		opstr = 0;
		goto icont;
	}
Comment 10 leonardo 2008-01-25 00:21:40 UTC
We decided to go with a different fix, which has been committed as 
http://ghostscript.com/pipermail/gs-cvs/2008-January/008087.html