[gs-cvs] rev 8504 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Fri Jan 25 00:17:17 PST 2008
Author: leonardo
Date: 2008-01-25 00:17:16 -0800 (Fri, 25 Jan 2008)
New Revision: 8504
Modified:
trunk/gs/src/int.mak
trunk/gs/src/zchar1.c
Log:
Fix (Font renderer) : Horizontal metrics sometimes applied with WMode 1 fonts.
DETAILS :
Bug 689464 "Japanese font writing direction (vertical ?)".
Bug 689646 "vertical text rendered by external CIDFontType0 flows horizontal".
1. When a descendent font of a type 0 CID font has zero FontBBox,
use the FontBBox of the CID font. This is another case when
a 3d party software generates a font with zero FontBBox.
We believe that such font data is incorrect,
but this patch provides a simple workaround.
2. When FontBBox to be used to compute Metrics2,
don't obtain sbw from type 1 glyph descriptions.
The old code does so causing the horizontal metrics
to be used when rendering a WMode 1 font.
3. The case (2) appears to have an exception,
when the font has CDevProc. In this case
we do need sbw from the glyph description
to provide arguments for CDevProc.
See alse the comment added to code.
Note that Type 1 font renderer now depends on some knowledge about type 0 CID font.
But this dependence does not break the configurability
because only an .h file is included into the Type 1 font renderer.
EXPECTED DIFFERENCES :
Minor difference in glyph positions :
"289-01.ps"
"Bug687832.pdf"
"Bug687846.ps"
"Bug688000.ps"
"Bug688308.ps"
"Bug688789.pdf"
"CIDembedded.pdf"
"Openhuis_pdf_zw.pdf"
"RodinCIDEmbed.pdf"
"shading_prob_800.ps"
"Svd.pdf"
"test.pdf"
Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak 2008-01-23 21:13:16 UTC (rev 8503)
+++ trunk/gs/src/int.mak 2008-01-25 08:17:16 UTC (rev 8504)
@@ -735,7 +735,7 @@
$(PSOBJ)zchar1.$(OBJ) : $(PSSRC)zchar1.c $(OP) $(memory__h)\
$(gscencs_h) $(gspaint_h) $(gspath_h) $(gsrect_h) $(gsstruct_h)\
$(gxdevice_h) $(gxfixed_h) $(gxmatrix_h)\
- $(gxfont_h) $(gxfont1_h) $(gxtype1_h) $(gxchar_h) $(gzstate_h)\
+ $(gxfont_h) $(gxfont1_h) $(gxtype1_h) $(gxfcid_h) $(gxchar_h) $(gzstate_h)\
$(estack_h) $(ialloc_h) $(ichar_h) $(ichar1_h) $(icharout_h)\
$(idict_h) $(ifont_h) $(igstate_h) $(iname_h) $(iutil_h) $(store_h)
$(PSCC) $(PSO_)zchar1.$(OBJ) $(C_) $(PSSRC)zchar1.c
Modified: trunk/gs/src/zchar1.c
===================================================================
--- trunk/gs/src/zchar1.c 2008-01-23 21:13:16 UTC (rev 8503)
+++ trunk/gs/src/zchar1.c 2008-01-25 08:17:16 UTC (rev 8504)
@@ -23,6 +23,7 @@
#include "gxfont.h"
#include "gxfont1.h"
#include "gxtype1.h"
+#include "gxfcid.h"
#include "gxchar.h"
#include "gzstate.h" /* for path for gs_type1_init */
/* (should only be gsstate.h) */
@@ -183,8 +184,17 @@
const gs_type1_data *pdata;
gs_type1exec_state cxs;
gs_type1_state *const pcis = &cxs.cis;
+ gs_rect FontBBox = pfont1->FontBBox;
int code;
+ if (penum->current_font->FontType == ft_CID_encrypted) {
+ if (FontBBox.q.x <= FontBBox.p.x && FontBBox.q.y <= FontBBox.p.y) {
+ gs_font_cid0 *pfcid0 = (gs_font_cid0 *)penum->current_font;
+
+ FontBBox = pfcid0->FontBBox;
+ }
+ }
+
pdata = &pfont1->data;
/*
* Any reasonable implementation would execute something like
@@ -240,8 +250,8 @@
if (code < 0)
return code;
gs_type1_set_callback_data(pcis, &cxs);
- if (pfont1->FontBBox.q.x > pfont1->FontBBox.p.x &&
- pfont1->FontBBox.q.y > pfont1->FontBBox.p.y
+ if (FontBBox.q.x > FontBBox.p.x &&
+ FontBBox.q.y > FontBBox.p.y
) {
/* The FontBBox appears to be valid. */
op_proc_t exec_cont = 0;
@@ -350,6 +360,7 @@
gs_font_base *const pbfont = (gs_font_base *) pfont;
op_proc_t cont = (pbfont->PaintType == 0 && penum->orig_font->PaintType == 0
? bbox_finish_fill : bbox_finish_stroke);
+ ref *pcdevproc;
/*
@@ -357,9 +368,18 @@
* this character, start interpreting the CharString; do the
* setcachedevice as soon as we know the (side bearing and) width.
*/
- if (pcxs->present == metricsNone) {
- /* Get the width from the CharString, */
- /* then set the cache device. */
+ if ((pcxs->present == metricsNone && !pcxs->use_FontBBox_as_Metrics2) ||
+ (penum->orig_font->WMode && zchar_get_CDevProc(pbfont, &pcdevproc))) {
+ /* Get the width from the CharString,
+ * then set the cache device. */
+ /* We pass here when WMode==1 and the font has CDevProc,
+ * because we do need sbw as CDevProc's argument.
+ * A more natural way would be not setting pcxs->use_FontBBox_as_Metrics2
+ * when the font has CDevProc, except for missing sbw in the glyph.
+ * We prefer to pass here because we've got examples
+ * of Tyoe 1 fonts with empty glyphs, i.e. with no sbw,
+ * so we don't want to assume that they'll never appear in a CID font.
+ * In that case penum->FontBBox_as_Metrics2 will go here to zchar_set_cache. */
ref cnref;
ref other_subr;
int code;
More information about the gs-cvs
mailing list