[gs-cvs] rev 7635 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Jan 22 07:44:31 PST 2007
Author: leonardo
Date: 2007-01-22 07:44:31 -0800 (Mon, 22 Jan 2007)
New Revision: 7635
Modified:
trunk/gs/src/gdevpdti.c
trunk/gs/src/gdevpdtt.c
Log:
Fix (pdfwrite) : Handle an invalid Type 3 font that misses setcharwidth, setcachedevice[2].
DETAILS :
Bug 688895 "ps2pdf aborts with "Error: /unregistered in --show--"".
The test document embeds an invalid Type 3 font : the character /s32 calls neither
setcachedevice nor setcachedevice2 nor setcharwidth.
PLRM3 page 339 reads :
[beg quote]
BuildGlyph must execute one of the following operators to pass width and
bounding box information to the PostScript interpreter. This must precede
execution of any path construction or painting operators describing the glyph.
setcachedevice establishes a single set of metrics for both writing modes, and
requests that the interpreter save the results in the font cache if possible.
setcachedevice2 (LanguageLevel 2) establishes separate sets of metrics for
writing modes 0 and 1, and requests that the interpreter save the results in the font
cache.
setcharwidth passes just the glyph's width (to be used only once), and
requests that the glyph not be cached. This operator is typically used only if the glyph
description includes operators to set the color explicitly.
[end quote]
Adobe appears to handle such fonts silently in both Postscript and PDF.
This patch provides same behavior.
The difference from the old code appears pretty small :
the old code set the charproc_accum flag while executing pdf_text_set_cache,
and the new one does when entering the substream.
The new code even more natural.
In the PDF output, for incorrect glyphs the Width array element
is set to zero, and d0, d1 operators are not written into the charproc.
Printing a warning about the incorrect charproc appears difficult
due to the necessity to suppress redundant messages.
It needs to add a new field into the gs_font structure.
We do not like to modify the general gs_font structure for such small reason.
Postponing this change until it is requested in prcatice.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevpdti.c
===================================================================
--- trunk/gs/src/gdevpdti.c 2007-01-22 14:34:04 UTC (rev 7634)
+++ trunk/gs/src/gdevpdti.c 2007-01-22 15:44:31 UTC (rev 7635)
@@ -487,8 +487,6 @@
(float)pw[3], (float)pw[4], (float)pw[5]);
pdfont->u.simple.s.type3.cached[ch >> 3] |= 0x80 >> (ch & 7);
}
- pdev->font3 = (pdf_resource_t *)pdfont;
- pdev->substream_Resources = pdfont->u.simple.s.type3.Resources;
return 0;
}
Modified: trunk/gs/src/gdevpdtt.c
===================================================================
--- trunk/gs/src/gdevpdtt.c 2007-01-22 14:34:04 UTC (rev 7634)
+++ trunk/gs/src/gdevpdtt.c 2007-01-22 15:44:31 UTC (rev 7635)
@@ -182,7 +182,6 @@
fallbacks to default implementations of graphic objects.
Hopely such fallbacks are rare. */
pdev->clip_path_id = gx_get_clip_path_id(penum_s->pgs);
- penum->charproc_accum = true;
return code;
} else {
gs_matrix m;
@@ -206,6 +205,7 @@
changes, which the charproc possibly did. */
gs_matrix_multiply((gs_matrix *)&pdev->charproc_ctm, (gs_matrix *)&penum->pis->ctm, &m);
gs_matrix_fixed_from_matrix(&penum->pis->ctm, &m);
+ penum->charproc_accum = false;
}
}
if (penum->pte_default) {
@@ -2440,6 +2440,7 @@
/* The condition above must be consistent with one in pdf_text_set_cache,
which decides to apply pdf_set_charproc_attrs. */
gs_matrix m;
+ pdf_font_resource_t *pdfont;
code = pdf_start_charproc_accum(pdev);
if (code < 0)
@@ -2466,6 +2467,12 @@
code = pdf_choose_output_char_code(pdev, penum, &penum->output_char_code);
if (code < 0)
return code;
+ code = pdf_attached_font_resource(pdev, penum->current_font, &pdfont, NULL, NULL, NULL, NULL);
+ if (code < 0)
+ return code;
+ pdev->font3 = (pdf_resource_t *)pdfont;
+ pdev->substream_Resources = pdfont->u.simple.s.type3.Resources;
+ penum->charproc_accum = true;
return TEXT_PROCESS_RENDER;
} else
code += 0; /* A fgood place for breakpoint. */
More information about the gs-cvs
mailing list