summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2009-04-16 16:00:34 +0000
committerKen Sharp <ken.sharp@artifex.com>2009-04-16 16:00:34 +0000
commit3d6bca4bf14edcdf8e69bf3ea1dfda552c0606a0 (patch)
tree13849d4b032076b8306fa390c88aa4451b820314
parentdc3137eb30ab0602415125f32ff97c227bb6dfc8 (diff)
Fix (pdfwrite): Ignore missing side bearing/width in type 1 fonts.
Details: Bug #689573: "glyphs with no (h)sbw cause error with pdfwrite". Fonts which contain glyphs that do not begin with a sbw or hsbw operator are technically invalid, but Acrobat Distiller, and other PostScript rips, ignore the error and render the glyph with a side bearing and width of 0. Modified the type 1 font code and the type 1 to type 2 (CFF) conversion code to assume that such glyphs have a width and side bearing of 0 and are not a cause for error. EXPECTED DIFFERENCES: None. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9647 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/base/gdevpsfx.c4
-rw-r--r--gs/base/gstype1.c13
-rw-r--r--gs/base/gxtype1.c7
3 files changed, 21 insertions, 3 deletions
diff --git a/gs/base/gdevpsfx.c b/gs/base/gdevpsfx.c
index 0b8902655..a064820f4 100644
--- a/gs/base/gdevpsfx.c
+++ b/gs/base/gdevpsfx.c
@@ -464,8 +464,8 @@ psf_convert_type1_to_type2(stream *s, const gs_glyph_data_t *pgd,
END
fixed mx0 = 0, my0 = 0; /* See ce1_setcurrentpoint. */
- /* Quiet a Coverity uninitialsed variable warning */
- cis.lsb.y = 0;
+ /* In case we do not get an sbw or hsbw op */
+ cis.lsb.x = cis.lsb.y = cis.width.x = cis.width.y = fixed_0;
/*
* Do a first pass to collect hints. Note that we must also process
diff --git a/gs/base/gstype1.c b/gs/base/gstype1.c
index d5b285213..c93bcce3e 100644
--- a/gs/base/gstype1.c
+++ b/gs/base/gstype1.c
@@ -283,6 +283,19 @@ gs_type1_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
goto cc;
case cx_endchar:
if (pcis->seac_accent < 0) {
+ if(!pcis->sb_set && !pcis->width_set) {
+ /* No sbw/hsbw op, error condition but Adobe interpreters ignore it.
+ Rewind the data pointer to the beginning of the glyph, re-initialise
+ the hinter, execute a '0' sbw op, and then carry on as if we had
+ actually received one. */
+ cip = pgd->bits.data;
+ t1_hinter__init(h, pcis->path);
+ code = t1_hinter__sbw(h, fixed_0, fixed_0, fixed_0, fixed_0);
+ if (code < 0)
+ return code;
+ gs_type1_sbw(pcis, fixed_0, fixed_0, fixed_0, fixed_0);
+ goto rsbw;
+ }
code = t1_hinter__endglyph(h);
if (code < 0)
return code;
diff --git a/gs/base/gxtype1.c b/gs/base/gxtype1.c
index 18e236e93..f3db192d9 100644
--- a/gs/base/gxtype1.c
+++ b/gs/base/gxtype1.c
@@ -573,7 +573,12 @@ gs_type1_glyph_info(gs_font *font, gs_glyph glyph, const gs_matrix *pmat,
code = pdata->interpret(&cis, &gdata, &value);
switch (code) {
case 0: /* done with no [h]sbw, error */
- code = gs_note_error(gs_error_invalidfont);
+ /* Adobe interpreters ignore the error! */
+ info->width[wmode].x = 0;
+ info->width[wmode].y = 0;
+ info->v.x = 0;
+ info->v.y = 0;
+ break;
default: /* code < 0, error */
return code;
case type1_result_callothersubr: /* unknown OtherSubr */